Skip to content

Commit 2afe05d

Browse files
authored
Merge pull request #16 from alexkunin/master
Test deep association queries in Doctrine2::seeInRepository
2 parents c6ec340 + 54cb4fe commit 2afe05d

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"white-october/pagerfanta-bundle": "^1.1"
3636
},
3737
"require-dev": {
38-
"codeception/codeception": "2.5.x-dev",
38+
"codeception/codeception": "3.0.x-dev",
3939
"friendsofphp/php-cs-fixer": "^2.7",
4040
"symfony/browser-kit": "^4.0",
4141
"symfony/css-selector": "^4.0",

tests/functional/CommentCest.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,31 @@ public function createComment(FunctionalTester $I)
2121
$I->submitForm('#post-add-comment > form', []);
2222
$I->seeCurrentRouteIs('blog_post');
2323
$I->see('Hi, Symfony!');
24-
$I->seeInRepository(Comment::class, ['content' => 'Hi, Symfony!']);
24+
// This particular assertion is a bit of overkill, but it also serves as a testcase
25+
// of `seeInRepository` method with complex associations. Here is how this assertion
26+
// translates to English:
27+
//
28+
// * I see a comment entity with content equal to 'Hi, Symfony!'
29+
// * and 'author' association points to a user entity with username equal to 'john_user'
30+
// ** note: john_user is one who created the comment, as it is used in login
31+
// procedure above
32+
// * and 'post' association points to a post entity which...
33+
// * ...has an associated comment entity which...
34+
// * ...has same content and author with same username.
35+
$I->seeInRepository(Comment::class, [
36+
'content' => 'Hi, Symfony!',
37+
'author' => [
38+
'username' => 'john_user',
39+
],
40+
'post' => [
41+
'comments' => [
42+
'content' => 'Hi, Symfony!',
43+
'author' => [
44+
'username' => 'john_user'
45+
]
46+
]
47+
]
48+
]);
2549
}
2650

27-
}
51+
}

0 commit comments

Comments
 (0)