You are here

public function FootermapBlockTest::testBuild in footermap: a footer site map 8

Asserts that site map is built.

File

tests/src/Unit/Plugin/Block/FootermapBlockTest.php, line 212

Class

FootermapBlockTest
Test footermap block methods.

Namespace

Drupal\Tests\footermap\Unit\Plugin\Block

Code

public function testBuild() {
  $block = $this
    ->getPlugin();
  $block
    ->setConfigurationValue('footermap_avail_menus', [
    'menu1' => 'menu1',
  ]);

  // Assert that site map is built with children.
  $map = $block
    ->build();
  $this
    ->assertArrayHasKey('#footermap', $map);
  $this
    ->assertArrayHasKey('#attached', $map);
  $this
    ->assertEquals('Footermap', $map['#title']);
  $this
    ->assertCount(1, $map['#footermap']['menu1']['#items']);
  $this
    ->assertEquals('Link1', $map['#footermap']['menu1']['#items']['menu-0']['#title']);
  $children =& $map['#footermap']['menu1']['#items']['menu-0']['#children'];
  $this
    ->assertEquals('Child Link 1', $children['menu-0']['#title']);

  // Assert that the site map has the menu links with #weight property equal
  // to the menu link weight.
  $this
    ->assertEquals(-5, $children['menu-1']['#weight']);
  $this
    ->assertEquals(5, $children['menu-0']['#weight']);
}