commit 60a523826e1c16daabc3d1d92894913afba2a14a
Author: Pieter Frenssen <pieter@frenssen.be>
Date:   Sun Jan 18 00:02:08 2015 +0100

    50

diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
index d587db2..488adf4 100644
--- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
@@ -331,16 +331,88 @@ public function testPrint() {
 
     $content = $this->randomMachineName();
     $html = '<div' . (string) $attribute . '>' . $content . '</div>';
-    $this->assertSelectEquals('div.example-class', $content, 1, $html);
-    $this->assertSelectEquals('div.example-class2', $content, 0, $html);
+    $this->assertClass('example-class', $html);
+    $this->assertNoClass('example-class2', $html);
 
-    $this->assertSelectEquals('div#example-id', $content, 1, $html);
-    $this->assertSelectEquals('div#example-id2', $content, 0, $html);
+    $this->assertID('example-id', $html);
+    $this->assertNoID('example-id2', $html);
 
     $this->assertTrue(strpos($html, 'enabled') !== FALSE);
   }
 
   /**
+   * Checks that the given CSS class is present in the given HTML snippet.
+   *
+   * @param string $class
+   *   The CSS class to check.
+   * @param string $html
+   *   The HTML snippet to check.
+   */
+  protected function assertClass($class, $html) {
+    $xpath = "//*[@class='$class']";
+    self::assertTrue((bool) $this->getXPathResultCount($xpath, $html));
+  }
+
+  /**
+   * Checks that the given CSS class is not present in the given HTML snippet.
+   *
+   * @param string $class
+   *   The CSS class to check.
+   * @param string $html
+   *   The HTML snippet to check.
+   */
+  protected function assertNoClass($class, $html) {
+    $xpath = "//*[@class='$class']";
+    self::assertFalse((bool) $this->getXPathResultCount($xpath, $html));
+  }
+
+  /**
+   * Checks that the given CSS ID is present in the given HTML snippet.
+   *
+   * @param string $id
+   *   The CSS ID to check.
+   * @param string $html
+   *   The HTML snippet to check.
+   */
+  protected function assertID($id, $html) {
+    $xpath = "//*[@id='$id']";
+    self::assertTrue((bool) $this->getXPathResultCount($xpath, $html));
+  }
+
+  /**
+   * Checks that the given CSS ID is not present in the given HTML snippet.
+   *
+   * @param string $id
+   *   The CSS ID to check.
+   * @param string $html
+   *   The HTML snippet to check.
+   */
+  protected function assertNoID($id, $html) {
+    $xpath = "//*[@id='$id']";
+    self::assertFalse((bool) $this->getXPathResultCount($xpath, $html));
+  }
+
+  /**
+   * Counts the occurrences of the given XPath query in a given HTML snippet.
+   *
+   * @param string $query
+   *   The XPath query to execute.
+   * @param string $html
+   *   The HTML snippet to check.
+   *
+   * @return int
+   *   The number of results that are found.
+   */
+  protected function getXPathResultCount($query, $html) {
+    $document = new \DOMDocument;
+    $document->preserveWhiteSpace = FALSE;
+    $document->loadHTML($html);
+    $xpath = new \DOMXPath($document);
+
+    return $xpath->query($query)->length;
+  }
+
+  /**
    * Tests the storage method.
    */
   public function testStorage() {
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index 1f371fa..df0ad23 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -430,7 +430,7 @@ public function testGenerateActive() {
       'tag' => 'a',
       'attributes' => array(
         'data-drupal-link-system-path' => 'test-route-3',
-        'data-drupal-link-query' => 'regexp:/.*value.*example_1.*/',
+        'data-drupal-link-query' => '{"value":"example_1"}',
       ),
     ), $result);
 
@@ -445,11 +445,44 @@ public function testGenerateActive() {
       'tag' => 'a',
       'attributes' => array(
         'data-drupal-link-system-path' => 'test-route-4/1',
-        'data-drupal-link-query' => 'regexp:/.*value.*example_1.*/',
+        'data-drupal-link-query' => '{"value":"example_1"}',
       ),
     ), $result);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function assertTag($matcher, $actual, $message = '', $isHtml = TRUE) {
+    // The parent method is deprecated in PHPUnit 4.2. This is an alternative
+    // implementation that covers the use cases in this test.
+    // Provide default values.
+    $matcher += array('attributes' => array());
+
+    // Create an XPath query to select the requested tag.
+    $query = '//' . $matcher['tag'];
+
+    // Append XPath predicates for the attributes and content text.
+    $predicates = array();
+    foreach ($matcher['attributes'] as $attribute => $value) {
+      $predicates[] = "@$attribute='$value'";
+    }
+    if (!empty($matcher['content'])) {
+      $predicates[] = "contains(.,'{$matcher['content']}')";
+    }
+    if (!empty($predicates)) {
+      $query .= '[' . implode(' and ', $predicates) . ']';
+    }
+
+    // Execute the query.
+    $document = new \DOMDocument;
+    $document->preserveWhiteSpace = FALSE;
+    $document->loadHTML($actual);
+    $xpath = new \DOMXPath($document);
+
+    self::assertEquals(1, $xpath->query($query)->length);
+  }
+
 }
 
 }
