Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder with rename test #277

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/Doctrine/Tests/ODM/PHPCR/Functional/ReorderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ public function testReorder()
$this->assertSame(array('second', 'first', 'third', 'fourth'), $this->getChildrenNames($parent->getChildren()));
}

public function testReorderWithRename()
{
$first = $this->dm->find(null, '/functional/source/first');
$this->assertNotNull($first);

$first->setNodeName('renamed');
$this->dm->persist($first);

$parent = $this->dm->find(null, '/functional/source');

$children = $parent->getChildren();

$this->assertEquals($children->first()->getNodeName(), $first->getNodeName());
var_dump($children->first()->getNodeName());
var_dump($this->getChildrenNames($children));
$this->assertSame($this->childrenNames, $this->getChildrenNames($children));

$this->dm->reorder($parent, 'renamed', 'second', false);
$this->dm->flush();
$this->dm->clear();

$parent = $this->dm->find(null, '/functional/source');
$this->assertSame(array('second', 'first', 'third', 'fourth'), $this->getChildrenNames($parent->getChildren()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would expect the array to be 'second', 'renamed', 'third', 'forth' - that was the point of renaming... however, we get 'renamed' first as the reorder does not work, the child will still have the old name 'first' at the point when reorder is calculated.

}

public function testReorderNoop()
{
$parent = $this->dm->find(null, '/functional/source');
Expand Down