public function DomainHookTest::testHookDomainValidate in Domain Access 8
Tests domain validation.
File
- domain/
tests/ src/ Kernel/ DomainHookTest.php, line 105
Class
- DomainHookTest
- Tests domain hooks documented in domain.api.php.
Namespace
Drupal\Tests\domain\KernelCode
public function testHookDomainValidate() {
$validator = \Drupal::service('domain.validator');
// Test a good domain.
$errors = $validator
->validate('one.example.com');
$this
->assertEmpty($errors, 'No errors returned for example.com');
// Test our hook implementation, which denies fail.example.com explicitly.
$errors = $validator
->validate('fail.example.com');
$this
->assertNotEmpty($errors, 'Errors returned for fail.example.com');
$this
->assertTrue(current($errors) == 'Fail.example.com cannot be registered', 'Error message returned correctly.');
}