Skip to content

Commit

Permalink
[tests] simplify grouped sortable position test
Browse files Browse the repository at this point in the history
  • Loading branch information
l3pp4rd committed Jul 30, 2013
1 parent 5a6ab37 commit 7ba748c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/Gedmo/Sortable/SortableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,14 @@ public function shouldShiftPositionForward()
$nodes = $repo->getBySortableGroups(array('path' => '/'));

$this->assertEquals('Node1', $nodes[0]->getName());
$this->assertEquals(0, $nodes[0]->getPosition());
$this->assertEquals('Node3', $nodes[1]->getName());
$this->assertEquals(1, $nodes[1]->getPosition());
$this->assertEquals('Node4', $nodes[2]->getName());
$this->assertEquals(2, $nodes[2]->getPosition());
$this->assertEquals('Node2', $nodes[3]->getName());
$this->assertEquals(3, $nodes[3]->getPosition());
$this->assertEquals('Node5', $nodes[4]->getName());
$this->assertEquals(4, $nodes[4]->getPosition());

for ($i = 0; $i < count($nodes); $i++) {
$this->assertSame($i, $nodes[$i]->getPosition());
}
}

/**
Expand Down Expand Up @@ -161,20 +160,20 @@ public function shouldShiftPositionBackward()
$node2->setPosition(1);
$this->em->persist($node2);
$this->em->flush();
$this->em->clear(); // to reload from database

$repo = $this->em->getRepository(self::NODE);
$nodes = $repo->getBySortableGroups(array('path' => '/'));

$this->assertEquals('Node1', $nodes[0]->getName());
$this->assertEquals(0, $nodes[0]->getPosition());
$this->assertEquals('Node4', $nodes[1]->getName());
$this->assertEquals(1, $nodes[1]->getPosition());
$this->assertEquals('Node2', $nodes[2]->getName());
$this->assertEquals(2, $nodes[2]->getPosition());
$this->assertEquals('Node3', $nodes[3]->getName());
$this->assertEquals(3, $nodes[3]->getPosition());
$this->assertEquals('Node5', $nodes[4]->getName());
$this->assertEquals(4, $nodes[4]->getPosition());

for ($i = 0; $i < count($nodes); $i++) {
$this->assertSame($i, $nodes[$i]->getPosition());
}
}

/**
Expand Down

0 comments on commit 7ba748c

Please sign in to comment.