diff --git a/core/modules/system/config/tour.tour.extend.yml b/core/modules/system/config/tour.tour.extend.yml new file mode 100644 index 0000000..c3bc5ff --- /dev/null +++ b/core/modules/system/config/tour.tour.extend.yml @@ -0,0 +1,72 @@ +id: modules +module: system +label: 'Extend' +langcode: en +routes: + - route_name: system.modules_list +tips: + modules-main: + id: modules-main + plugin: text + label: 'Extending your site (adding modules)' + weight: '1' + body: 'Use this page to add, remove, update or enable modules on your site.' + modules-install: + id: modules-install + plugin: text + label: 'Installing modules' + weight: '2' + body: 'Use this action link to install a module. There are thousands of contributed modules available for download at Drupal.org.' + attributes: + data-class: 'action-links' + modules-search: + id: modules-search + plugin: text + label: 'Finding modules' + weight: '3' + body: 'This list can get quite long so theres a search field to quickly jump you to the one you are looking for.' + attributes: + data-class: 'form-search' + modules-core: + id: modules-core + plugin: text + label: 'Core modules' + weight: '4' + location: top + body: 'This collapsible group contains the core modules in Drupal. Modules you add will be placed in other groups. You can disable core modules if no other modules depend on them.' + attributes: + data-id: 'edit-modules-core' + modules-block: + id: modules-block + plugin: text + label: 'Module information' + weight: '5' + body: 'Use the checkbox to enable or disable modules. Remember to save before leaving the page.' + attributes: + data-id: 'module-block' + modules-open-details: + id: modules-open-details + plugin: text + label: 'Module details' + weight: '6' + body: 'Now click the small arrow beside "Controls the visual building blocks..." then continue the tour.' + attributes: + data-id: 'module-block' + modules-details-expanded: + id: modules-details-expanded + plugin: text + label: 'Module details open' + weight: '7' + body: 'View modules that require this module, modules this module requires and links to help, permissions (who can use the module), and module configuration (not all modules are configurable).' + attributes: + data-id: 'edit-modules-core-block-links-help' + modules-save: + id: modules-save + plugin: text + location: top + label: 'Saving' + weight: '8' + body: 'Don't forget to save your changes.' + attributes: + data-id: 'edit-actions' +status: '1' diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ExtendTourTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ExtendTourTest.php new file mode 100644 index 0000000..46950ab --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ExtendTourTest.php @@ -0,0 +1,47 @@ + 'Extend page tour tests', + 'description' => 'Tests the Extend(module admin) page tour.', + 'group' => 'Tour', + ); + } + + /** + * Tests extends tour tip availability. + */ + public function testExtendTourTips() { + // Visit the extend page. + $this->drupalGet('admin/modules'); + $this->assertTourTips(); + } +} diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php index 0beb7f0..dedc812 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php @@ -12,7 +12,38 @@ /** * Tests tour functionality. */ -class TourTestBase extends WebTestBase { +abstract class TourTestBase extends WebTestBase { + + /** + * An admin user with administrative permissions for extends. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * An array of permissions to grant an admin user to test tour output. + * + * Note \Drupal\tour\Tests\TourTestBase::setUp() will add 'access tour' and + * 'view the administration theme' to this list. + * + * @var array + */ + protected $adminPermissions = array(); + + /** + * Set the admin theme to seven for testing tour markup. + */ + protected function setUp() { + parent::setUp(); + // Set seven as the admin theme. + \Drupal::service('theme_handler')->enable(array('seven')); + \Drupal::config('system.theme')->set('admin', 'seven')->save(); + \Drupal::config('node.settings')->set('use_admin_theme', '1')->save(); + // Login an admin user. + $this->adminUser = $this->drupalCreateUser(array_merge($this->adminPermissions, array('access tour', 'view the administration theme'))); + $this->drupalLogin($this->adminUser); + } /** * Assert function to determine if tips rendered to the page @@ -56,10 +87,24 @@ public function assertTourTips($tips = array()) { foreach ($tips as $tip) { if (!empty($tip['data-id'])) { $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE); + if ($elements == 0) { + // Could be a html5 element that \PHPUnit_Util_XML::cssSelect() does + // not support, fallback to xpath. + $elements = $this->xpath('//*[@id = :id]', array( + ':id' => $tip['data-id'], + )); + } $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id']))); } else if (!empty($tip['data-class'])) { $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE); + if ($elements == 0) { + // Could be a html5 element that \PHPUnit_Util_XML::cssSelect() does + // not support, fallback to xpath. + $elements = $this->xpath('//*[@class = :class]', array( + ':class' => $tip['data-class'], + )); + } $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class']))); } else {