[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
|
||||
for (; $i < $length; ++$i) {
|
||||
unset($this->elements[$i], $this->isIndex[$i]);
|
||||
}
|
||||
$this->elements = \array_slice($this->elements, 0, $i);
|
||||
$this->isIndex = \array_slice($this->isIndex, 0, $i);
|
||||
} else {
|
||||
$diff = $insertionLength - $cutLength;
|
||||
|
||||
|
|
|
@ -285,4 +285,25 @@ class PropertyPathBuilderTest extends TestCase
|
|||
{
|
||||
$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