public function DomainAliasDomainDeleteTest::testDomainDelete in Domain Access 8
Tests alias deletion on domain deletion.
File
- domain_alias/
tests/ src/ Kernel/ DomainAliasDomainDeleteTest.php, line 55
Class
- DomainAliasDomainDeleteTest
- Tests that aliases are deleted on domain delete.
Namespace
Drupal\Tests\domain_alias\KernelCode
public function testDomainDelete() {
$domains = $this->domainStorage
->loadMultiple();
$patterns = [
'example_com' => '*.example.com',
'one_example_com' => 'foo.example.com',
];
// Create an alias.
foreach ($domains as $id => $domain) {
$values = [
'domain_id' => $domain
->id(),
'pattern' => $patterns[$id],
'redirect' => 0,
'environment' => 'local',
];
$this
->createDomainAlias($values);
$alias = $this->aliasStorage
->loadByPattern($patterns[$id]);
$this
->assertNotEmpty($alias, 'Alias saved properly');
}
// Delete one domain.
$domain
->delete();
$alias = $this->aliasStorage
->loadByPattern($patterns[$id]);
$this
->assertEmpty($alias, 'Alias deleted properly');
// Check the remaining domain, which should still have an alias.
$domain = $this->domainStorage
->load('example_com');
$alias = $this->aliasStorage
->loadByPattern($patterns[$domain
->id()]);
$this
->assertNotEmpty($alias, 'Alias retained properly');
}