diff --git a/examples.module b/examples.module index 1b764d6..f09110b 100644 --- a/examples.module +++ b/examples.module @@ -51,6 +51,7 @@ function examples_toolbar() { 'plugin_type_example' => 'plugin_type_example.description', 'simpletest_example' => 'simpletest_example_description', 'tour_example' => 'tour_example_description', + 'vertical_tabs_example' => 'vertical_tabs_example.description', ); // Build a list of links for the menu. diff --git a/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php b/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php index fba58e3..5ba8b0a 100644 --- a/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php +++ b/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php @@ -10,25 +10,29 @@ namespace Drupal\vertical_tabs_example\Controller; use Drupal\Core\Url; /** - * Class VerticalTabsExampleController + * Class VerticalTabsExampleController. + * * @package Drupal\vertical_tabs_example\Controller */ class VerticalTabsExampleController { + /** * A simple controller method to explain the vertical tabs example. */ public function description() { $url = Url::fromRoute('node.add_page'); - $content_add = \Drupal::l(t('content_add'), $url); + $content_add = \Drupal::l(t('add a piece of content'), $url); $build = array( '#markup' => t('The Vertical Tabs Example shows how a custom module can add a vertical tab to a node edit form, and support its summary field with JavaScript. To see the - effects of this module, !content_add and look at the set - of tabs at the bottom. We\'ve added one called \'Example vertical tab.\'', - array('!content_add' => $content_add) + effects of this module, !add a piece of content and look at the set + of tabs beside. We\'ve added one called \'Example vertical tab.\'', + array('!add a piece of content' => $content_add) ), ); return $build; + } + } diff --git a/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php b/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php index bf931ab..197ce5e 100644 --- a/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php +++ b/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php @@ -15,6 +15,7 @@ use Drupal\simpletest\WebTestBase; * Functional tests for the Vertical Tabs Example module. * * @ingroup vertical_tabs_examples + * * @group vertical_tabs_examples * @group examples */ @@ -30,12 +31,15 @@ class VerticalTabsExampleTest extends WebTestBase { * Tests the menu paths defined in vertical_tabs_example module. */ public function testVerticalTabsExampleMenus() { - $paths = array( - 'examples/vertical_tabs', - ); - foreach ($paths as $path) { - $this->drupalGet($path); - $this->assertResponse(200, '200 response for path: ' . $path); - } + // Verify links on front-page. + $this->drupalGet('examples/vertical_tabs'); + $this->assertResponse(200, '200 response for path: ' . $path); + $this->assertLinkByHref('node/add'); + // Verify vertical tab on node/add/article. + $this->drupalGet('node/add'); + $this->clickLink('Article'); + $this->assertFieldByXPath("//details[@id='edit-vertical-tabs-example']"); + } + } diff --git a/vertical_tabs_example/vertical_tabs_example.libraries.yml b/vertical_tabs_example/vertical_tabs_example.libraries.yml index 4a7d536..d665e15 100644 --- a/vertical_tabs_example/vertical_tabs_example.libraries.yml +++ b/vertical_tabs_example/vertical_tabs_example.libraries.yml @@ -1,5 +1,7 @@ +# Build up our dependencies as a library. vertical_tabs_example: version: 1.x + # Adding our js file. js: js/vertical_tabs_example.js: {} dependencies: