Loading core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php +4 −8 Original line number Diff line number Diff line Loading @@ -88,20 +88,16 @@ protected function doTestAggregation(array $settings): void { // Collect all the URLs for all the script and styles prior to making any // more requests. $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $script_elements = $page->findAll('xpath', '//script'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $script_elements = $page->findAll('xpath', '//script[@src]'); $style_urls = []; foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $style_urls[] = $element->getAttribute('href'); } } $script_urls = []; foreach ($script_elements as $element) { if ($element->hasAttribute('src')) { $script_urls[] = $element->getAttribute('src'); } } foreach ($style_urls as $url) { $this->assertAggregate($url); $this->assertAggregate($url, FALSE); Loading core/tests/Drupal/FunctionalTests/Asset/UnversionedAssetTest.php +25 −29 Original line number Diff line number Diff line Loading @@ -50,11 +50,10 @@ public function testUnversionedAssets(): void { $session = $this->getSession(); $page = $session->getPage(); $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $this->assertNotEmpty($style_elements); $href = NULL; foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $href = $element->getAttribute('href'); $url = $this->getAbsoluteUrl($href); // Not every script or style on a page is aggregated. Loading @@ -68,7 +67,6 @@ public function testUnversionedAssets(): void { $this->assertStringContainsString('original-content', $aggregate); $this->assertStringNotContainsString('extra-stuff', $aggregate); } } $file = file_get_contents('public://test.css') . '.extra-stuff{display:none;}'; file_put_contents('public://test.css', $file); // Clear the library discovery and page caches again so that new URLs are Loading @@ -78,10 +76,9 @@ public function testUnversionedAssets(): void { $this->drupalGet('<front>'); $session = $this->getSession(); $page = $session->getPage(); $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $this->assertNotEmpty($style_elements); foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $new_href = $element->getAttribute('href'); $this->assertNotSame($new_href, $href); $url = $this->getAbsoluteUrl($new_href); Loading @@ -97,6 +94,5 @@ public function testUnversionedAssets(): void { $this->assertStringContainsString('extra-stuff', $aggregate); } } } } Loading
core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php +4 −8 Original line number Diff line number Diff line Loading @@ -88,20 +88,16 @@ protected function doTestAggregation(array $settings): void { // Collect all the URLs for all the script and styles prior to making any // more requests. $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $script_elements = $page->findAll('xpath', '//script'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $script_elements = $page->findAll('xpath', '//script[@src]'); $style_urls = []; foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $style_urls[] = $element->getAttribute('href'); } } $script_urls = []; foreach ($script_elements as $element) { if ($element->hasAttribute('src')) { $script_urls[] = $element->getAttribute('src'); } } foreach ($style_urls as $url) { $this->assertAggregate($url); $this->assertAggregate($url, FALSE); Loading
core/tests/Drupal/FunctionalTests/Asset/UnversionedAssetTest.php +25 −29 Original line number Diff line number Diff line Loading @@ -50,11 +50,10 @@ public function testUnversionedAssets(): void { $session = $this->getSession(); $page = $session->getPage(); $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $this->assertNotEmpty($style_elements); $href = NULL; foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $href = $element->getAttribute('href'); $url = $this->getAbsoluteUrl($href); // Not every script or style on a page is aggregated. Loading @@ -68,7 +67,6 @@ public function testUnversionedAssets(): void { $this->assertStringContainsString('original-content', $aggregate); $this->assertStringNotContainsString('extra-stuff', $aggregate); } } $file = file_get_contents('public://test.css') . '.extra-stuff{display:none;}'; file_put_contents('public://test.css', $file); // Clear the library discovery and page caches again so that new URLs are Loading @@ -78,10 +76,9 @@ public function testUnversionedAssets(): void { $this->drupalGet('<front>'); $session = $this->getSession(); $page = $session->getPage(); $style_elements = $page->findAll('xpath', '//link[@rel="stylesheet"]'); $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]'); $this->assertNotEmpty($style_elements); foreach ($style_elements as $element) { if ($element->hasAttribute('href')) { $new_href = $element->getAttribute('href'); $this->assertNotSame($new_href, $href); $url = $this->getAbsoluteUrl($new_href); Loading @@ -97,6 +94,5 @@ public function testUnversionedAssets(): void { $this->assertStringContainsString('extra-stuff', $aggregate); } } } }