Verified Commit ca47a29e authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2441373 by twistor, vsujeetkumar, marvil07, eporama, daffie,...

Issue #2441373 by twistor, vsujeetkumar, marvil07, eporama, daffie, joseph.olstad, alvar0hurtad0, jibran, longwave, joelpittet, smustgrave, alexpott: Upgrade tests to HTML5

(cherry picked from commit 13883cc3)
parent cb017eb0
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public function testRenderLayout($layout_id, $config, $regions, array $html) {
    $build_id_input = $this->cssSelect('input[name="form_build_id"]')[0]->asXML();
    $form_id_input = '<input data-drupal-selector="edit-the-form-id" type="hidden" name="form_id" value="the_form_id"/>';
    $html[] = 'Test suffix';
    $html[] = $build_id_input . $form_id_input . '</form>';
    $html[] = $build_id_input . "\n" . $form_id_input . "\n" . '</form>';

    // Match the HTML to the full form element.
    $this->assertSame(implode("\n", $html), $this->cssSelect('#the-form-id')[0]->asXML());
+3 −6
Original line number Diff line number Diff line
@@ -480,8 +480,7 @@ public function testDrupalPreRenderLinks() {
    // it.
    $render_array = $base_array;
    $html = \Drupal::service('renderer')->renderRoot($render_array);
    $dom = new \DOMDocument();
    $dom->loadHTML($html);
    $dom = Html::load($html);
    $this->assertEquals(1, $dom->getElementsByTagName('ul')->length, 'One "ul" tag found in the rendered HTML.');
    $list_elements = $dom->getElementsByTagName('li');
    $this->assertEquals(3, $list_elements->length, 'Three "li" tags found in the rendered HTML.');
@@ -498,16 +497,14 @@ public function testDrupalPreRenderLinks() {
    $child_html = \Drupal::service('renderer')->renderRoot($render_array['first_child']);
    $parent_html = \Drupal::service('renderer')->renderRoot($render_array);
    // First check the child HTML.
    $dom = new \DOMDocument();
    $dom->loadHTML($child_html);
    $dom = Html::load($child_html);
    $this->assertEquals(1, $dom->getElementsByTagName('ul')->length, 'One "ul" tag found in the rendered child HTML.');
    $list_elements = $dom->getElementsByTagName('li');
    $this->assertEquals(2, $list_elements->length, 'Two "li" tags found in the rendered child HTML.');
    $this->assertEquals('Parent link copy', $list_elements->item(0)->nodeValue, 'First expected link found.');
    $this->assertEquals('First child link', $list_elements->item(1)->nodeValue, 'Second expected link found.');
    // Then check the parent HTML.
    $dom = new \DOMDocument();
    $dom->loadHTML($parent_html);
    $dom = Html::load($parent_html);
    $this->assertEquals(1, $dom->getElementsByTagName('ul')->length, 'One "ul" tag found in the rendered parent HTML.');
    $list_elements = $dom->getElementsByTagName('li');
    $this->assertEquals(2, $list_elements->length, 'Two "li" tags found in the rendered parent HTML.');
+1 −2
Original line number Diff line number Diff line
@@ -177,8 +177,7 @@ protected function assertNotSubString(string $haystack, string $needle, string $
   *   An array containing simplexml objects.
   */
  protected function parseContent($content) {
    $htmlDom = new \DOMDocument();
    @$htmlDom->loadHTML('<?xml encoding="UTF-8">' . $content);
    $htmlDom = Html::load($content);
    $elements = simplexml_import_dom($htmlDom);

    return $elements;
+2 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\views\Kernel\Plugin;

use Drupal\Component\Utility\Html;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\row\RowTest;
@@ -309,8 +310,7 @@ public function testCustomRowClasses() {
   *   The HTML DOM.
   */
  protected function getHtmlDom($output) {
    $html_dom = new \DOMDocument();
    @$html_dom->loadHTML($output);
    $html_dom = Html::load($output);
    if ($html_dom) {
      // It's much easier to work with simplexml than DOM, luckily enough
      // we can just simply import our DOM tree.
+2 −3
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

namespace Drupal\Tests\views\Kernel\Plugin;

use Drupal\Component\Utility\Html;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Masterminds\HTML5;

/**
 * Tests some general style plugin related functionality.
@@ -21,8 +21,7 @@ abstract class StyleTestBase extends ViewsKernelTestBase {
   * Stores a view output in the elements.
   */
  public function storeViewPreview($output) {
    $html5 = new HTML5();
    $htmlDom = $html5->loadHTML('<html><body>' . $output . '</body></html>');
    $htmlDom = Html::load($output);
    if ($htmlDom) {
      // It's much easier to work with simplexml than DOM, luckily enough
      // we can just simply import our DOM tree.
Loading