Skip to content

Commit 8d3fba6

Browse files
committed
ITT: Optional params for specifying custom create relation method names - tests.
1 parent 1f060aa commit 8d3fba6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/TestingTools/Asserts/EloquentAssertsTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,24 @@ public function it_has_eloquent_has_create_relation_method_assertion()
5656
$this->assertEloquentHasCreateRelationMethod(Post::class, 'comments');
5757
}
5858

59+
/** @test */
60+
public function which_supports_optional_parameter_for_specifying_custom_create_method_name()
61+
{
62+
$this->assertEloquentHasCreateRelationMethod(Post::class, 'comments', 'attachComment');
63+
}
64+
5965
/** @test */
6066
public function it_has_eloquent_has_create_many_relations_method_assertion()
6167
{
6268
$this->assertEloquentHasCreateManyRelationsMethod(Post::class, 'comments');
6369
}
6470

71+
/** @test */
72+
public function which_also_supports_optional_parameter_for_specifying_custom_create_many_method_name()
73+
{
74+
$this->assertEloquentHasCreateManyRelationsMethod(Post::class, 'comments', 'attachManyComments');
75+
}
76+
6577
/** @test */
6678
public function it_has_eloquent_belongs_to_assertion()
6779
{

tests/TestingTools/fixture/app/Post.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ public function createManyComments(array $comments)
2323
{
2424
return $this->comments()->createMany($comments);
2525
}
26+
27+
public function attachComment(array $attributes)
28+
{
29+
return $this->createComment($attributes);
30+
}
31+
32+
public function attachManyComments(array $comments)
33+
{
34+
return $this->createManyComments($comments);
35+
}
2636
}

0 commit comments

Comments
 (0)