DomainCheckResponseTest.php in Domain Access 8
File
domain/tests/src/Functional/DomainCheckResponseTest.php
View source
<?php
namespace Drupal\Tests\domain\Functional;
class DomainCheckResponseTest extends DomainTestBase {
public function testDomainCheckResponse() {
$this->admin_user = $this
->drupalCreateUser([
'administer domains',
'create domains',
]);
$this
->drupalLogin($this->admin_user);
$storage = \Drupal::entityTypeManager()
->getStorage('domain');
$edit = $this
->domainPostValues();
$edit['hostname'] = 'example.com';
$this
->drupalGet('admin/config/domain/add');
$this
->submitForm($edit, 'Save');
$this
->assertNoRaw('The server request to');
$domains = $storage
->loadMultiple();
$this
->assertCount(1, $domains, 'Domain record saved via form.');
$edit = $this
->domainPostValues();
$edit['hostname'] = 'foo.bar';
$edit['id'] = $storage
->createMachineName($edit['hostname']);
$edit['validate_url'] = 1;
try {
$this
->drupalGet('admin/config/domain/add');
$this
->submitForm($edit, 'Save');
} catch (\Exception $e) {
}
$this
->assertRaw('The server request to');
$domains = $storage
->loadMultiple();
$this
->assertCount(1, $domains, 'Domain record not saved via form.');
$edit['validate_url'] = 0;
$this
->drupalGet('admin/config/domain/add');
$this
->submitForm($edit, 'Save');
$this
->assertNoRaw('The server request to');
$domains = $storage
->loadMultiple();
$this
->assertCount(2, $domains, 'Domain record saved via form.');
}
}