You are here

public function MenuLinkTreeElementTest::testCount in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php \Drupal\Tests\Core\Menu\MenuLinkTreeElementTest::testCount()

Tests count().

@covers ::count

File

core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php, line 37

Class

MenuLinkTreeElementTest
Tests the menu link tree element value object.

Namespace

Drupal\Tests\Core\Menu

Code

public function testCount() {
  $link_1 = MenuLinkMock::create([
    'id' => 'test_1',
  ]);
  $link_2 = MenuLinkMock::create([
    'id' => 'test_2',
  ]);
  $child_item = new MenuLinkTreeElement($link_2, FALSE, 2, FALSE, []);
  $parent_item = new MenuLinkTreeElement($link_1, FALSE, 2, FALSE, [
    $child_item,
  ]);
  $this
    ->assertSame(1, $child_item
    ->count());
  $this
    ->assertSame(2, $parent_item
    ->count());
}