diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
index dcadd3f..7aaa71e 100644
--- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
+++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
@@ -8,12 +8,12 @@
namespace Drupal\tour\Tests;
use Drupal\Core\Language\Language;
-use Drupal\simpletest\WebTestBase;
+use Drupal\tour\Tests\TourTestBase;
/**
* Tests tour functionality.
*/
-class TourTest extends WebTestBase {
+class TourTest extends TourTestBase {
/**
* Modules to enable.
@@ -48,6 +48,7 @@ public function testTourFunctionality() {
':text' => 'The first tip',
));
$this->assertEqual(count($elements), 1, 'Found English variant of tip 1.');
+ $this->assertTourTips();
$elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array(
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 even last',
diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php
new file mode 100644
index 0000000..e9eede9
--- /dev/null
+++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php
@@ -0,0 +1,67 @@
+assertTourTips();
+ *
+ * // Advanced example:
+ * $tips = array();
+ * $tips[] = array('data-id' => 'foo');
+ * $tips[] = array('data-id' => 'bar');
+ * $tips[] = array('data-class' => 'baz');
+ * $this->assertTourTips($tips);
+ * @endcode
+ */
+ public function assertTourTips($tips = array()) {
+ // Get the rendered tips and there data-id and data-class attributes.
+ if (empty($tips)) {
+ // Tips are rendered as
elements inside .
+ $rendered_tips = $this->xpath('//ol[@id = "tour"]//li');
+ foreach ($rendered_tips as $rendered_tip) {
+ $attributes = (array) $rendered_tip->attributes();
+ $tips[] = $attributes['@attributes'];
+ }
+ }
+
+ // If the tips are still empty we need to fail.
+ if (empty($tips)) {
+ $this->fail(t('Could not find tour tips on the current page.'));
+ }
+ else {
+ // Check for corresponding page elements.
+ foreach ($tips as $tip) {
+ if (!empty($tip['data-id'])) {
+ $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE);
+ $this->assertTrue(count($elements), 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);
+ $this->assertTrue(count($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class'])));
+ }
+ }
+ }
+ }
+
+}
diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTestSimple.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTestSimple.php
new file mode 100644
index 0000000..0789582
--- /dev/null
+++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTestSimple.php
@@ -0,0 +1,68 @@
+ array(
+ * array('data-id' => 'foo'),
+ * array('data-class' => 'bar'),
+ * ),
+ * );
+ * @endcode
+ */
+ protected $tips = array();
+
+ /**
+ * An admin user with administrative permissions for views.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
+ /**
+ * The permissions required for a logged in user to test tour tips.
+ *
+ * @var array
+ * A list of permissions.
+ */
+ protected $permissions = array('access tour');
+
+ /**
+ * Create an admin user to view tour tips.
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->adminUser = $this->drupalCreateUser($this->permissions);
+ $this->drupalLogin($this->adminUser);
+ }
+
+ /**
+ * A simple tip test.
+ */
+ public function testTips() {
+ foreach ($this->tips as $path => $attributes) {
+ $this->drupalGet($path);
+ $this->assertTourTips($attributes);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Controller/TourTestController.php b/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Controller/TourTestController.php
index 73b7cde..62aa705 100644
--- a/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Controller/TourTestController.php
+++ b/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Controller/TourTestController.php
@@ -33,6 +33,13 @@ public function tourTest1() {
),
'#children' => t('Where does the rain in Spain fail?'),
),
+ 'tip-3' => array(
+ '#type' => 'container',
+ '#attributes' => array(
+ 'id' => 'tour-test-3',
+ ),
+ '#children' => t('Tip created now?'),
+ ),
'tip-4' => array(
'#type' => 'container',
'#attributes' => array(
@@ -40,6 +47,13 @@ public function tourTest1() {
),
'#children' => t('Tip created later?'),
),
+ 'code-tip-1' => array(
+ '#type' => 'container',
+ '#attributes' => array(
+ 'id' => 'tour-code-test-1',
+ ),
+ '#children' => t('Tip created now?'),
+ ),
);
}
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php
index 739e98d..c15e2ca 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php
@@ -7,27 +7,26 @@
namespace Drupal\views_ui\Tests;
-use Drupal\Core\Language\Language;
-use Drupal\simpletest\WebTestBase;
+use Drupal\tour\Tests\TourTestBase;
/**
* Tests tour functionality.
*/
-class ViewsUITourTest extends UITestBase {
+class ViewsUITourTest extends TourTestBase {
/**
- * Modules to enable.
+ * An admin user with administrative permissions for views.
*
- * @var array
+ * @var \Drupal\user\UserInterface
*/
- public static $modules = array('tour');
+ protected $adminUser;
/**
- * Views used by this test.
+ * Modules to enable.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $modules = array('views_ui', 'tour');
public static function getInfo() {
return array(
@@ -39,16 +38,23 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('access tour', 'administer views')));
+ $this->adminUser = $this->drupalCreateUser(array('administer views', 'access tour'));
+ $this->drupalLogin($this->adminUser);
}
/**
- * Tests the Views UI tour.
+ * Tests views_ui tour tip availability.
*/
- public function testTourFunctionality() {
- $this->drupalGet('admin/structure/views/view/test_view');
- $elements = $this->xpath('//ol[@id="tour"]');
- $this->assertEqual(count($elements), 1, 'Found a tour on the test view.');
+ public function testViewsUiTourTips() {
+ // Create a basic view that shows all content, with a page and a block
+ // display.
+ $view['label'] = $this->randomName(16);
+ $view['id'] = strtolower($this->randomName(16));
+ $view['page[create]'] = 1;
+ $view['page[path]'] = $this->randomName(16);
+ $view_path = $view['page[path]'];
+ $this->drupalPost('admin/structure/views/add', $view, t('Save and edit'));
+ $this->assertTourTips();
}
}