Resolve #3304219 "Allow underscore in"
9 open threads
9 open threads
Closes #3304219
Merge request reports
Activity
added 2 commits
added 1 commit
added 1 commit
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; 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.');
Please register or sign in to reply