DomainConfigCacheTest.php in Domain Access 8
File
domain_config/tests/src/Functional/DomainConfigCacheTest.php
View source
<?php
namespace Drupal\Tests\domain_config\Functional;
class DomainConfigCacheTest extends DomainConfigTestBase {
public static $modules = [
'domain_access',
'domain_config',
];
public function testDomainResponse() {
$this
->domainTableIsEmpty();
$this
->domainCreateTestDomains(5);
$expected = [];
$domains = \Drupal::entityTypeManager()
->getStorage('domain')
->loadMultiple(NULL, TRUE);
foreach ($domains as $domain) {
$this
->drupalGet($domain
->getPath());
$expected[] = $domain
->getPath() . ':';
}
$database = \Drupal::database();
$query = $database
->query("SELECT cid FROM {cache_page}");
$result = $query
->fetchCol();
$this
->assertEqual(sort($expected), sort($result), 'Cache returns as expected.');
$ids = [
'example_com',
'four_example_com',
];
$node1 = $this
->drupalCreateNode([
'type' => 'article',
'field_domain_access' => [
$ids,
],
'path' => '/test',
]);
$original = $expected;
foreach ($domains as $domain) {
$this
->drupalGet($domain
->getPath() . 'test');
$expected[] = $domain
->getPath() . 'test:';
}
$query = $database
->query("SELECT cid FROM {cache_page}");
$result = $query
->fetchCol();
$this
->assertEqual(sort($expected), sort($result), 'Cache returns as expected.');
$node1
->delete();
$query = $database
->query("SELECT cid FROM {cache_page}");
$result = $query
->fetchCol();
$this
->assertEqual(sort($original), sort($result), 'Cache returns as expected.');
}
}