You are here

public static function ImporterTest::assertMenuLinkCreated in GatherContent 8.4

Assert menu link creation.

1 call to ImporterTest::assertMenuLinkCreated()
ImporterTest::testImport in tests/src/Kernel/ImporterTest.php
Test the import function.

File

tests/src/Kernel/ImporterTest.php, line 81

Class

ImporterTest
Tests for the importer class.

Namespace

Drupal\Tests\gathercontent\Kernel

Code

public static function assertMenuLinkCreated($parentMenuName, $menuTitle) {
  $menus = MenuLinkContent::loadMultiple();
  $menusInParent = array_filter($menus, function ($menu) use ($parentMenuName, $menuTitle) {

    /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu */
    $isSameParentMenu = $menu
      ->getMenuName() === $parentMenuName;
    $isSameMenuName = $menu
      ->getTitle() === $menuTitle;
    return $isSameMenuName && $isSameParentMenu;
  });
  static::assertEquals(1, count($menusInParent), "Didn't find '{$menuTitle}' in '{$parentMenuName}' parent menu.");
}