Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Use iterator in tests for node names
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Jun 30, 2016
1 parent 6a57cc2 commit 988579a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Repository/PhpcrOdmRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function reorderNode($sourcePath, $position)
$document = $this->getDocument($sourcePath);
$node = $this->getManager()->getNodeForDocument($document);
$parent = $node->getParent();
$nodeNames = $parent->getNodeNames();
$nodeNames = iterator_to_array($parent->getNodeNames());
$parentDocument = $this->getManager()->find(null, $parent->getPath());

if (isset($nodeNames[$position + 1])) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Repository/PhpcrOdmRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ private function doTestReorder($position, $before)
$this->documentManager->getNodeForDocument($this->child1)->willReturn($this->node1->reveal());
$this->node1->getParent()->willReturn($this->node2->reveal());
$this->node1->getName()->willReturn('foo');
$this->node2->getNodeNames()->willReturn([
$this->node2->getNodeNames()->willReturn(new \ArrayIterator([
'foo', 'bar', 'baz',
]);
]));
$this->node2->getPath()->willReturn('/test');
$this->documentManager->find(null, '/test')->willReturn($this->document);
$this->documentManager->reorder($this->document, 'foo', 'baz', $before)->shouldBeCalled();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Repository/PhpcrRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ public function testReorder()
$this->node->getPath()->willReturn($evaluatedPath);
$this->node->getParent()->willReturn($this->node1->reveal());
$this->node->getName()->willReturn('node-1');
$this->node1->getNodeNames()->willReturn([
$this->node1->getNodeNames()->willReturn(new \ArrayIterator([
'node-1', 'node-2', 'node-3',
]);
]));

$this->node1->orderBefore('node-1', 'node-3')->shouldBeCalled();
$this->session->save()->shouldBeCalled();
Expand Down

0 comments on commit 988579a

Please sign in to comment.