I am using the SQLite in memory to test my Laravel application. Then i define one table Enterprise this way:
Schema::create('Enterprise', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->integer('address')->unsigned()->index()->nullable();
$table->foreign('address_id')->references('id')
->on('Address')->onDelete('cascade');
$table->timestamps();
});
the address schema:
Schema::create('Address', function(Blueprint $table)
{
$table->increments('id');
$table->timestamps();
});
But, when i run the test
$emp = Enterprise::find(1)->first();
$emp->delete();
$this->assertEquals(0, Enterprise::all()->count());
$this->assertEquals(0, Address::all()->count());
the test fails in the second assert, it is not deleting in cascade :(
Anyone knows the solution ??
Aucun commentaire:
Enregistrer un commentaire