diff --git a/menu_example/menu_example.info.yml b/menu_example/menu_example.info.yml new file mode 100644 index 0000000..fc71778 --- /dev/null +++ b/menu_example/menu_example.info.yml @@ -0,0 +1,7 @@ +name: Menu_example +type: module +description: 'An example module showing how to define and handling menu links in drupal 8.' +package: 'Example modules' +core: 8.x +dependencies: + - examples diff --git a/menu_example/menu_example.module b/menu_example/menu_example.module new file mode 100644 index 0000000..3c24425 --- /dev/null +++ b/menu_example/menu_example.module @@ -0,0 +1,8 @@ +assertTrue(\Drupal::moduleHandler()->moduleExists('menu_example')); + } + + /** + * Test the various menus. + */ + public function testMenuExample() { + $this->drupalGet(''); + $this->clickLink(t('Menu Example')); + $this->assertText(t('This is the base page of the Menu Example')); + + $this->clickLink(t('Custom Access Example')); + $this->assertText(t('Custom Access Example')); + + $this->clickLink(t('examples/menu_example/custom_access/page')); + $this->assertResponse(403); + + $this->drupalGet('examples/menu_example/permissioned'); + $this->assertText(t('Permissioned Example')); + + $this->clickLink('examples/menu_example/permissioned/controlled'); + $this->assertResponse(403); + + $this->drupalGet('examples/menu_example'); + + $this->clickLink(t('MENU_CALLBACK example')); + + $this->drupalGet('examples/menu_example/path_only/callback'); + $this->assertText(t('The menu entry for this page is of type MENU_CALLBACK')); + + $this->clickLink(t('Tabs')); + $this->assertText(t('This is the "tabs" menu entry')); + + $this->drupalGet('examples/menu_example/tabs/second'); + $this->assertText(t('This is the tab "second" in the "basic tabs" example')); + + $this->clickLink(t('third')); + $this->assertText(t('This is the tab "third" in the "basic tabs" example')); + + $this->clickLink(t('Extra Arguments')); + + $this->drupalGet('examples/menu_example/use_url_arguments/one/two'); + $this->assertText(t('Argument 1=one')); + + $this->clickLink(t('Placeholder Arguments')); + + $this->clickLink(t('examples/menu_example/placeholder_argument/3343/display')); + $this->assertRaw('