Skip to content
Snippets Groups Projects

Resolve #3304219 "Allow underscore in"

Closes #3304219

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Drupal\Tests\menu_ui\Functional;
6
7 use Drupal\Tests\BrowserTestBase;
8
9 /**
10 * Tests creating a menu with an underscore in the machine name.
11 *
12 * @group menu_ui
  • 1 name: 'Menu UI Test'
  • 19 protected static $modules = [
    20 'menu_ui',
    21 'menu_ui_test',
    22 ];
    23
    24 /**
    25 * {@inheritdoc}
    26 */
    27 protected $defaultTheme = 'stark';
    28
    29 /**
    30 * A user with permission to administer menus.
    31 *
    32 * @var \Drupal\user\UserInterface
    33 */
    34 protected $adminUser;
  • 37 * {@inheritdoc}
    38 */
    39 protected function setUp(): void {
    40 parent::setUp();
    41
    42 // Create and log in an admin user with menu permissions.
    43 $this->adminUser = $this->drupalCreateUser([
    44 'administer menu',
    45 ]);
    46 $this->drupalLogin($this->adminUser);
    47 }
    48
    49 /**
    50 * Tests that a menu can be created with an underscore in the machine name.
    51 */
    52 public function testMenuMachineNameWithUnderscore(): void {
  • 1 <?php
    2
    3 declare(strict_types=1);
    4
    5 namespace Drupal\Tests\menu_ui\Unit;
    6
    7 use Drupal\Core\Form\FormState;
    8 use Drupal\Core\Language\LanguageInterface;
    9 use Drupal\menu_ui\MenuForm;
    10 use Drupal\system\MenuInterface;
    11 use Drupal\Tests\UnitTestCase;
    12
    13 /**
    14 * @coversDefaultClass \Drupal\menu_ui\MenuForm
    15 * @group menu_ui
  • 9 use Drupal\menu_ui\MenuForm;
    10 use Drupal\system\MenuInterface;
    11 use Drupal\Tests\UnitTestCase;
    12
    13 /**
    14 * @coversDefaultClass \Drupal\menu_ui\MenuForm
    15 * @group menu_ui
    16 */
    17 class MenuFormTest extends UnitTestCase {
    18
    19 /**
    20 * The menu entity mock.
    21 *
    22 * @var \Drupal\system\MenuInterface|\PHPUnit\Framework\MockObject\MockObject
    23 */
    24 protected $menu;
  • 16 */
    17 class MenuFormTest extends UnitTestCase {
    18
    19 /**
    20 * The menu entity mock.
    21 *
    22 * @var \Drupal\system\MenuInterface|\PHPUnit\Framework\MockObject\MockObject
    23 */
    24 protected $menu;
    25
    26 /**
    27 * The MenuForm under test.
    28 *
    29 * @var \Drupal\menu_ui\MenuForm|\PHPUnit\Framework\MockObject\MockObject
    30 */
    31 protected $form;
  • 1 <?php
    2
    3 declare(strict_types=1);
    4
    5 namespace Drupal\Tests\menu_ui\Unit;
    6
    7 use Drupal\Core\Form\FormState;
    8 use Drupal\Core\Language\LanguageInterface;
    9 use Drupal\menu_ui\MenuForm;
    10 use Drupal\system\MenuInterface;
    11 use Drupal\Tests\UnitTestCase;
    12
    13 /**
  • 50 * Tests that a menu can be created with an underscore in the machine name.
    51 */
    52 public function testMenuMachineNameWithUnderscore(): void {
    53 $this->drupalGet('admin/structure/menu/add');
    54 $this->assertSession()->statusCodeEquals(200);
    55
    56 // Fill and submit the form.
    57 $edit = [
    58 'label' => 'My Custom Menu',
    59 'id' => 'custom_menu_test',
    60 'description' => 'Testing underscores in menu ID',
    61 ];
    62 $this->submitForm($edit, 'Save');
    63
    64 // Check for confirmation message.
    65 $this->assertSession()->pageTextContains('Menu My Custom Menu has been added.');
  • Stephen Mustgrave left review comments

    left review comments

  • Please register or sign in to reply
    Loading