MenuLinkTreeElementTest.php in Zircon Profile 8
File
core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php
View source
<?php
namespace Drupal\Tests\Core\Menu;
use Drupal\Core\Menu\MenuLinkTreeElement;
use Drupal\Tests\UnitTestCase;
class MenuLinkTreeElementTest extends UnitTestCase {
public function testConstruction() {
$link = MenuLinkMock::create(array(
'id' => 'test',
));
$item = new MenuLinkTreeElement($link, FALSE, 3, FALSE, array());
$this
->assertSame($link, $item->link);
$this
->assertSame(FALSE, $item->hasChildren);
$this
->assertSame(3, $item->depth);
$this
->assertSame(FALSE, $item->inActiveTrail);
$this
->assertSame(array(), $item->subtree);
}
public function testCount() {
$link_1 = MenuLinkMock::create(array(
'id' => 'test_1',
));
$link_2 = MenuLinkMock::create(array(
'id' => 'test_2',
));
$child_item = new MenuLinkTreeElement($link_2, FALSE, 2, FALSE, array());
$parent_item = new MenuLinkTreeElement($link_1, FALSE, 2, FALSE, array(
$child_item,
));
$this
->assertSame(1, $child_item
->count());
$this
->assertSame(2, $parent_item
->count());
}
}