Skip to content
Snippets Groups Projects
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
Branches
Tags
20 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained,!5674Transaction autocommit during shutdown relies on unreliable object destruction order,!5644Issue #3395563 by nireneko, marvil07, lauriii, borisson_, smustgrave, Wim...
Pipeline #44743 passed
Pipeline: drupal

#44744

    ......@@ -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());
    ......
    ......@@ -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.');
    ......
    ......@@ -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,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,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.
    ......
    ......@@ -122,14 +122,12 @@ protected function setDrupalSettings($settings) {
    */
    protected function parse() {
    if (!isset($this->elements)) {
    // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
    // them.
    $html_dom = new \DOMDocument();
    @$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent(), LIBXML_NOBLANKS);
    if ($html_dom) {
    $content = $this->getRawContent();
    $dom = Html::load($content);
    if ($dom) {
    // It's much easier to work with simplexml than DOM, luckily enough
    // we can just simply import our DOM tree.
    $this->elements = simplexml_import_dom($html_dom);
    $this->elements = @simplexml_import_dom($dom);
    }
    }
    $this->assertNotFalse($this->elements, 'The current HTML page should be available for DOM navigation.');
    ......
    ......@@ -2,6 +2,7 @@
    namespace Drupal\Tests\Core\Template;
    use Drupal\Component\Render\MarkupInterface;
    use Drupal\Component\Utility\Html;
    use Drupal\Core\Render\Markup;
    use Drupal\Core\Template\Attribute;
    ......@@ -9,7 +10,6 @@
    use Drupal\Core\Template\AttributeString;
    use Drupal\Core\Template\Loader\StringLoader;
    use Drupal\Tests\UnitTestCase;
    use Drupal\Component\Render\MarkupInterface;
    use Twig\Environment;
    /**
    ......@@ -447,8 +447,7 @@ protected function assertNoID(string $id, string $html): void {
    * The number of results that are found.
    */
    protected function getXPathResultCount($query, $html) {
    $document = new \DOMDocument();
    $document->loadHTML($html);
    $document = Html::load($html);
    $xpath = new \DOMXPath($document);
    return $xpath->query($query)->length;
    ......
    ......@@ -3,6 +3,8 @@
    namespace Drupal\Tests\Core\Utility;
    use Drupal\Component\Render\MarkupInterface;
    use Drupal\Component\Utility\Html;
    use Drupal\Core\DependencyInjection\ContainerBuilder;
    use Drupal\Core\GeneratedButton;
    use Drupal\Core\GeneratedNoLink;
    use Drupal\Core\GeneratedUrl;
    ......@@ -12,7 +14,6 @@
    use Drupal\Core\Url;
    use Drupal\Core\Utility\LinkGenerator;
    use Drupal\Tests\UnitTestCase;
    use Drupal\Core\DependencyInjection\ContainerBuilder;
    /**
    * @coversDefaultClass \Drupal\Core\Utility\LinkGenerator
    ......@@ -676,8 +677,7 @@ public static function assertLink(array $properties, MarkupInterface $html, int
    }
    // Execute the query.
    $document = new \DOMDocument();
    $document->loadHTML($html);
    $document = Html::load($html);
    $xpath = new \DOMXPath($document);
    self::assertEquals($count, $xpath->query($query)->length);
    ......@@ -694,8 +694,7 @@ public static function assertLink(array $properties, MarkupInterface $html, int
    * @internal
    */
    protected function assertNoXPathResults(string $query, string $html): void {
    $document = new \DOMDocument();
    $document->loadHTML($html);
    $document = Html::load($html);
    $xpath = new \DOMXPath($document);
    self::assertFalse((bool) $xpath->query($query)->length);
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment