From 93b9f5842664971cc82920a219503a28b0a69096 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Thu, 21 Dec 2017 10:57:43 +0000
Subject: [PATCH] Issue #2932044 by alexpott: Remove
 \PHPUnit_Util_XML::cssSelect() from \Drupal\tour\Tests\TourTestBase

---
 core/modules/tour/src/Tests/TourTest.php     | 83 ++++++++++++++++++++
 core/modules/tour/src/Tests/TourTestBase.php |  4 +-
 2 files changed, 85 insertions(+), 2 deletions(-)
 create mode 100644 core/modules/tour/src/Tests/TourTest.php

diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/src/Tests/TourTest.php
new file mode 100644
index 000000000000..738bae8e2ae9
--- /dev/null
+++ b/core/modules/tour/src/Tests/TourTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Drupal\tour\Tests;
+
+/**
+ * A legacy test for \Drupal\tour\Tests\TourTestBase.
+ *
+ * @group tour
+ */
+class TourTest extends TourTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['block', 'tour', 'locale', 'language', 'tour_test'];
+
+  /**
+   * Tour tip attributes to be tested. Keyed by the path.
+   *
+   * @var array
+   *   An array of tip attributes, keyed by path.
+   */
+  protected $tips = [
+    'tour-test-1' => [
+      'data-id' => 'tour-test-1',
+      'data-class' => 'tour-test-1',
+    ],
+  ];
+
+  /**
+   * An admin user with administrative permissions for tour.
+   *
+   * @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 = ['access tour'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Make sure we are using distinct default and administrative themes for
+    // the duration of these tests.
+    $this->container->get('theme_handler')->install(['bartik', 'seven']);
+    $this->config('system.theme')
+      ->set('default', 'bartik')
+      ->set('admin', 'seven')
+      ->save();
+
+    $this->permissions[] = 'view the administration theme';
+
+    // Create an admin user to view tour tips.
+    $this->adminUser = $this->drupalCreateUser($this->permissions);
+    $this->drupalLogin($this->adminUser);
+
+    $this->drupalPlaceBlock('local_actions_block', [
+      'theme' => 'seven',
+      'region' => 'content'
+    ]);
+  }
+
+  /**
+   * A simple tip test.
+   */
+  public function testTips() {
+    foreach ($this->tips as $path => $attributes) {
+      $this->drupalGet($path);
+      $this->assertTourTips($attributes);
+    }
+  }
+
+}
diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/src/Tests/TourTestBase.php
index e13965070678..eca2ef8a1574 100644
--- a/core/modules/tour/src/Tests/TourTestBase.php
+++ b/core/modules/tour/src/Tests/TourTestBase.php
@@ -55,11 +55,11 @@ public function assertTourTips($tips = []) {
       $modals = 0;
       foreach ($tips as $tip) {
         if (!empty($tip['data-id'])) {
-          $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE);
+          $elements = $this->xpath('//*[@id="' . $tip['data-id'] . '"]');
           $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', ['%data-id' => $tip['data-id']]));
         }
         elseif (!empty($tip['data-class'])) {
-          $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE);
+          $elements = $this->xpath('//*[contain(@class, "' . $tip['data-id'] . '")]');
           $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', ['%data-class' => $tip['data-class']]));
         }
         else {
-- 
GitLab