Skip to content
Snippets Groups Projects

Resolve #3445095 "Responsive image test 5.x"

Open Wim Leers requested to merge issue/cdn-3445095:3445095-responsive_image_test-5.x into 5.x
Files
2
<?php
declare(strict_types=1);
namespace Drupal\Tests\cdn\Functional;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Tests\responsive_image\Functional\ResponsiveImageFieldDisplayTest as CoreTest;
use Drupal\Tests\UiHelperTrait;
/**
* @group cdn
*/
class ResponsiveImageFieldDisplayTest extends CoreTest {
use UiHelperTrait {
buildUrl as coreBuildUrlWithBrokenSchemeLessUrlSupport;
}
/**
* {@inheritdoc}
*/
protected static $modules = ['cdn'];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Configure CDN integration.
$this->config('cdn.settings')
->set('mapping', [
'type' => 'simple',
// Specify a host that resolves in the test environment.
'domain' => parse_url($GLOBALS['base_url'], PHP_URL_HOST),
'conditions' => [],
])
->set('status', TRUE)
// Disable the farfuture functionality: simpler file URL assertions.
->set('farfuture', ['status' => FALSE])
->save();
// Rebuild the container to ensure the reconstructed `CdnSettings` service
// is used by the CDN module's file URL generator decorator service.
$this->rebuildContainer();
$this->fileUrlGenerator = $this->container->get(FileUrlGeneratorInterface::class);
// TRICKY: necessary to avoid triggering an exception in ThemeManager.
// @see \Drupal\Core\Theme\ThemeManager::render()
$this->container->get(ModuleHandlerInterface::class)->reload();
}
/**
* {@inheritdoc}
*/
protected function buildUrl($path, array $options = []) {
// @todo Remove this when \Drupal\Tests\UiHelperTrait::buildUrl() is fixed.
// Support scheme-relative URLs.
if (is_string($path) && str_starts_with($path, '//')) {
return $path;
}
return $this->coreBuildUrlWithBrokenSchemeLessUrlSupport($path, $options);
}
}
Loading