Skip to content

Commit 514301f

Browse files
Add test case for invalid relationship methods
1 parent 6b1394a commit 514301f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/CascadeSoftDeletesIntegrationTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,26 @@ public function it_takes_excepion_to_models_that_do_not_implement_soft_deletes()
7575
new Tests\Entities\Comment(['body' => 'This is the third test comment']),
7676
]);
7777

78-
$this->assertCount(3, $post->comments);
78+
$post->delete();
79+
}
80+
81+
/**
82+
* @test
83+
* @expectedException \RuntimeException
84+
*/
85+
public function it_takes_exception_to_models_trying_to_cascade_deletes_on_invalid_relationships()
86+
{
87+
$post = Tests\Entities\InvalidRelationshipPost::create([
88+
'title' => 'Testing invalid cascade relationships',
89+
'body' => 'Ensure you can only use this trait if the model defines valid relationships',
90+
]);
91+
92+
$post->comments()->saveMany([
93+
new Tests\Entities\Comment(['body' => 'This is the first test comment']),
94+
new Tests\Entities\Comment(['body' => 'This is the second test comment']),
95+
new Tests\Entities\Comment(['body' => 'This is the third test comment']),
96+
]);
97+
7998
$post->delete();
8099
}
81100
}

0 commit comments

Comments
 (0)