You are here

public function DevelGenerateBrowserTest::testDevelGenerateMenus in Devel 4.x

Same name and namespace in other branches
  1. 8.3 devel_generate/tests/src/Functional/DevelGenerateBrowserTest.php \Drupal\Tests\devel_generate\Functional\DevelGenerateBrowserTest::testDevelGenerateMenus()

Tests generating menus.

@todo Add test coverage to check:

  • title_length is not exceeded.
  • max_depth and max_width work as designed.
  • generating links in existing menus, and then deleting them with kill.
  • using specific link_types settings only create those links.

File

devel_generate/tests/src/Functional/DevelGenerateBrowserTest.php, line 288

Class

DevelGenerateBrowserTest
Tests the logic to generate data.

Namespace

Drupal\Tests\devel_generate\Functional

Code

public function testDevelGenerateMenus() {
  $edit = [
    'num_menus' => 5,
    'num_links' => 7,
  ];
  $this
    ->drupalPostForm('admin/config/development/generate/menu', $edit, 'Generate');
  $this
    ->assertSession()
    ->pageTextContains('Created the following 5 new menus: ');
  $this
    ->assertSession()
    ->pageTextContains('Created 7 new menu links');
  $this
    ->assertSession()
    ->pageTextContains('Generate process complete.');

  // Use big numbers for menus and links, but short text, to test for clashes.
  // Also verify the kill option.
  $edit = [
    'num_menus' => 160,
    'num_links' => 380,
    'title_length' => 3,
    'kill' => 1,
  ];
  $this
    ->drupalPostForm('admin/config/development/generate/menu', $edit, 'Generate');
  $this
    ->assertSession()
    ->pageTextContains('Deleted 5 menu(s) and 0 other link(s).');
  $this
    ->assertSession()
    ->pageTextContains('Created the following 160 new menus: ');
  $this
    ->assertSession()
    ->pageTextContains('Created 380 new menu links');
  $this
    ->assertSession()
    ->pageTextContains('Generate process complete.');
}