mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 19:58:53 +02:00
Fixed infinite loop when an element gets assigned itself as parent
This fixes issue #230
This commit is contained in:
parent
d1b8a36b93
commit
7394a23a83
5 changed files with 32 additions and 4 deletions
|
@ -144,4 +144,15 @@ class AbstractStructuralDBElementTest extends TestCase
|
|||
$this->assertSame([$this->root, $this->child1], $this->child1->getPathArray());
|
||||
$this->assertSame([$this->root], $this->root->getPathArray());
|
||||
}
|
||||
|
||||
public function testGetSubelements(): void
|
||||
{
|
||||
$this->assertSame([$this->child1, $this->child2, $this->child3], $this->root->getSubelements()->toArray());
|
||||
$this->assertSame([$this->child1_1, $this->child1_2], $this->child1->getSubelements()->toArray());
|
||||
$this->assertSame([], $this->child1_1->getSubelements()->toArray());
|
||||
|
||||
//If a element is set as its own parent, it should not be returned as a subelement
|
||||
$this->child1->setParent($this->child1);
|
||||
$this->assertSame([], $this->child1->getSubelements()->toArray());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue