public function DomainCSSTest::testDomainNegotiator in Domain Access 8
Tests the handling of an inbound request.
File
- domain/
tests/ src/ Functional/ DomainCSSTest.php, line 32
Class
- DomainCSSTest
- Tests the domain CSS configuration.
Namespace
Drupal\Tests\domain\FunctionalCode
public function testDomainNegotiator() {
// No domains should exist.
$this
->domainTableIsEmpty();
// Create four new domains programmatically.
$this
->domainCreateTestDomains(4);
// The test runner doesn't use a theme that contains the preprocess hook,
// so set to use Bartik.
$config = $this
->config('system.theme');
$config
->set('default', 'bartik')
->save();
// Test the response of the default home page.
foreach (\Drupal::entityTypeManager()
->getStorage('domain')
->loadMultiple() as $domain) {
$this
->drupalGet($domain
->getPath());
$text = '<body class="' . Html::getClass($domain
->id() . '-class');
$this
->assertNoRaw($text, 'No custom CSS present.');
}
// Set the css classes.
$config = $this
->config('domain.settings');
$config
->set('css_classes', '[domain:machine-name]-class')
->save();
// Test the response of the default home page.
foreach (\Drupal::entityTypeManager()
->getStorage('domain')
->loadMultiple() as $domain) {
// The render cache trips up this test. In production, it may be
// necessary to add the url.site cache context. See README.md.
drupal_flush_all_caches();
$this
->drupalGet($domain
->getPath());
$text = '<body class="' . Html::getClass($domain
->id() . '-class');
$this
->assertRaw($text, 'Custom CSS present.' . $text);
}
// Set the css classes.
$config = $this
->config('domain.settings');
$config
->set('css_classes', '[domain:machine-name]-class [domain:name]-class')
->save();
// Test the response of the default home page.
foreach (\Drupal::entityTypeManager()
->getStorage('domain')
->loadMultiple() as $domain) {
// The render cache trips up this test. In production, it may be
// necessary to add the url.site cache context. See README.md.
drupal_flush_all_caches();
$this
->drupalGet($domain
->getPath());
$text = '<body class="' . Html::getClass($domain
->id() . '-class') . ' ' . Html::getClass($domain
->label() . '-class');
$this
->assertRaw($text, 'Custom CSS present.' . $text);
}
}