bug #17112 [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace (alekitto)

This PR was merged into the 2.3 branch.

Discussion
----------

[PropertyAccess] Reorder elements array after PropertyPathBuilder::replace

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17102
| License       | MIT
| Doc PR        |

Commits
-------

d0c0294 [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace
This commit is contained in:
Tobias Schultze 2015-12-22 19:03:17 +01:00
commit 7f5245c633
2 changed files with 12 additions and 0 deletions

View File

@ -142,6 +142,7 @@ class PropertyPathBuilder
$this->elements[$offset + $i] = $path->getElement($pathOffset + $i);
$this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i);
}
ksort($this->elements);
}
/**

View File

@ -252,6 +252,17 @@ class PropertyPathBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($path, $builder->getPropertyPath());
}
public function testReplaceWithLongerPathKeepsOrder()
{
$path = new PropertyPath('new1.new2.new3');
$expected = new PropertyPath('new1.new2.new3.old2');
$builder = new PropertyPathBuilder(new PropertyPath('old1.old2'));
$builder->replace(0, 1, $path);
$this->assertEquals($expected, $builder->getPropertyPath());
}
public function testRemove()
{
$this->builder->remove(3);