Skip to content
Open
Prev Previous commit
Next Next commit
fix: restore cases of ArrayAccess instead getChildren
  • Loading branch information
shakaran committed Dec 9, 2025
commit 584ec1e135bf7b0fc3acd15d54ed7e8fb0376a29
17 changes: 9 additions & 8 deletions tests/Knp/Menu/Tests/MenuItemTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ public function testCountable(): void

public function testGetChildren(): void
{
$children = $this->ch4->getChildren();
$this->assertCount(1, $children);
$this->assertEquals($this->gc1->getName(), $children['Grandchild 1']->getName());
$this->assertCount(1, $this->ch4->getChildren());
$this->assertSame($this->gc1, $this->ch4['Grandchild 1']);
}

public function testGetFirstChild(): void
Expand Down Expand Up @@ -233,8 +232,8 @@ public function testAddChildFailsIfInAnotherMenu(): void

public function testGetChild(): void
{
$this->assertSame($this->gc1, $this->ch4->getChild('Grandchild 1'));
$this->assertNull($this->ch4->getChild('nonexistentchild'));
$this->assertSame($this->gc1, $this->ch4['Grandchild 1']);
$this->assertNull($this->ch4['nonexistentchild']);
}

public function testRemoveChild(): void
Expand Down Expand Up @@ -274,9 +273,9 @@ public function testUpdateChildAfterRename(): void
$pt1 = $this->pt1;
$menu = $this->menu;
$pt1->setName('Temp name');
$this->assertSame($pt1, $menu->getChild('Temp name'));
$this->assertSame($pt1, $menu['Temp name']);
$this->assertEquals(['Temp name', 'Parent 2'], \array_keys($menu->getChildren()));
$this->assertNull($menu->getChild('Parent 1'));
$this->assertNull($menu['Parent 1']);
}

public function testRenameToExistingSiblingNameThrowAnException(): void
Expand All @@ -290,7 +289,9 @@ public function testGetUri(): void
{
$this->addChildWithExternalUrl();
$this->assertNull($this->pt1->getUri());
$this->assertEquals('http://www.symfony-reloaded.org', $this->menu->getChildren()['child']->getUri());
$child = $this->menu['child'];
/** @var ItemInterface $child */
$this->assertEquals('http://www.symfony-reloaded.org', $child->getUri());
}

protected function addChildWithExternalUrl(): void
Expand Down