[PropertyAccess] Fixed PropertyPathBuilder remove that fails to reset internal indexes
This commit is contained in:
parent
4203bef6f3
commit
479dff4f8a
@ -257,9 +257,8 @@ class PropertyPathBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All remaining elements should be removed
|
// All remaining elements should be removed
|
||||||
for (; $i < $length; ++$i) {
|
$this->elements = \array_slice($this->elements, 0, $i);
|
||||||
unset($this->elements[$i], $this->isIndex[$i]);
|
$this->isIndex = \array_slice($this->isIndex, 0, $i);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$diff = $insertionLength - $cutLength;
|
$diff = $insertionLength - $cutLength;
|
||||||
|
|
||||||
|
@ -285,4 +285,25 @@ class PropertyPathBuilderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->builder->remove(-1);
|
$this->builder->remove(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRemoveAndAppendAtTheEnd()
|
||||||
|
{
|
||||||
|
$this->builder->remove($this->builder->getLength() - 1);
|
||||||
|
|
||||||
|
$path = new PropertyPath('old1[old2].old3[old4][old5]');
|
||||||
|
|
||||||
|
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||||
|
|
||||||
|
$this->builder->appendProperty('old7');
|
||||||
|
|
||||||
|
$path = new PropertyPath('old1[old2].old3[old4][old5].old7');
|
||||||
|
|
||||||
|
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||||
|
|
||||||
|
$this->builder->remove($this->builder->getLength() - 1);
|
||||||
|
|
||||||
|
$path = new PropertyPath('old1[old2].old3[old4][old5]');
|
||||||
|
|
||||||
|
$this->assertEquals($path, $this->builder->getPropertyPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user