diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php index 19498e4..a7b8563 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTestBase.php @@ -8,7 +8,7 @@ namespace Drupal\tour\Tests; use Drupal\simpletest\WebTestBase; -//use Symfony\Component\CssSelector\CssSelector; +use Symfony\Component\CssSelector\CssSelector; /** * Tests tour functionality. @@ -106,14 +106,17 @@ function hasTipsOnPage(array $tour, array $tip_ids = array()) { $selector = array(); if (isset($attributes['data-id'])) { $selector[':data-id'] = $tip['attributes']['data-id']; + $this->tipOnPage($tip['id'], $selector); + $this->tipTargetOnPage($tip['id'], $selector); } if (isset($attributes['data-class'])) { $selector[':data-class'] = $tip['attributes']['data-class']; - } - if (!empty($selector)) { $this->tipOnPage($tip['id'], $selector); $this->tipTargetOnPage($tip['id'], $selector); } + if (!empty($selector)) { + $this->assertEqual(count($selector), 1, "Either select through data-id or data-class"); + } else { // Modal tip } @@ -129,6 +132,7 @@ function tipOnPage($tip_id, $selector) { $path .= '@data-id=:data-id and '; } if (isset($selector[':data-class'])) { + // No need to parse path as we select on data-class not on real class. $path .= '@data-class=:data-class and '; } $path .= ' ./h2]'; @@ -148,9 +152,9 @@ function tipOnPage($tip_id, $selector) { function tipTargetOnPage($tip_id, $selector) { $parts = array(); if (isset($selector[':data-id'])) { - $parts[] = '@id=:data-id'; + $path = '//*[' . '@id=:data-id' . ']'; } - if (isset($selector[':data-class'])) { + else if (isset($selector[':data-class'])) { // We need to convert css selector into xpath // // .views-ui-display-tab-bucket.filter-criteria .dropbutton-widget > .blink @@ -161,14 +165,10 @@ function tipTargetOnPage($tip_id, $selector) { // . => // // @see https://drupal.org/project/emogrifier // @see https://github.com/symfony/CssSelector - $path = trim($selector[':data-class']); - //$path = CssSelector::toXPath('.' . $selector[':data-class']); - //$this->verbose($path); - //$parts[] = $path; - $parts[] = 'contains(@class, :data-class)'; + $path = CssSelector::toXPath('.' . $selector[':data-class']); + $this->verbose($path); } // Target can be anything / anywhere. - $path = '//*[' . join(" and ", $parts) . ']'; $elements = $this->xpath($path, $selector); $this->assertEqual(count($elements), 1, format_string("Found target for selection '$path' on '$tip_id' ", $selector)); }