Skip to content

Commit

Permalink
improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Giberson committed Feb 11, 2016
1 parent ae78575 commit 0feaf92
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,17 @@ public function testManyToManyOrderByIsNotIgnored()
{
$user = $this->addCmsUserGblancoWithGroups(1);

$group = new CmsGroup;
$group->name = 'C';
$user->addGroup($group);
$group1 = new CmsGroup;
$group2 = new CmsGroup;
$group3 = new CmsGroup;

$group = new CmsGroup;
$group->name = 'A';
$user->addGroup($group);
$group1->name = 'C';
$group2->name = 'A';
$group3->name = 'B';

$group = new CmsGroup;
$group->name = 'B';
$user->addGroup($group);
$user->addGroup($group1);
$user->addGroup($group2);
$user->addGroup($group3);

$this->_em->persist($user);
$this->_em->flush();
Expand All @@ -405,14 +405,17 @@ public function testManyToManyOrderByIsNotIgnored()

$criteria = Criteria::create()
->orderBy(['name' => Criteria::ASC]);
$groups = $user->getGroups()->matching($criteria);

$existingOrder = [];
foreach ($groups as $group) {
$existingOrder[] = $group->getName();
}

$this->assertEquals(['A', 'B', 'C', 'Developers_0'], $existingOrder);
$this->assertEquals(
['A', 'B', 'C', 'Developers_0'],
$user
->getGroups()
->matching($criteria)
->map(function (CmsGroup $group) {
return $group->getName();
})
->toArray()
);
}

public function testMatchingWithLimit()
Expand Down

0 comments on commit 0feaf92

Please sign in to comment.