[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        |
This commit is contained in:
Alessandro Chitolina 2015-12-22 18:06:45 +01:00
parent d481dda329
commit d0c0294a7b
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);