DomainFormsTest.php in Domain Access 8
File
domain/tests/src/Functional/DomainFormsTest.php
View source
<?php
namespace Drupal\Tests\domain\Functional;
class DomainFormsTest extends DomainTestBase {
public function testDomainInterface() {
$this->admin_user = $this
->drupalCreateUser([
'administer domains',
'create domains',
]);
$this
->drupalLogin($this->admin_user);
$storage = \Drupal::entityTypeManager()
->getStorage('domain');
$this
->domainTableIsEmpty();
$this
->drupalGet('admin/config/domain');
$this
->assertText('There are no domain record entities yet.', 'Text for no domains found.');
$this
->drupalGet('admin/config/domain/add');
$edit = $this
->domainPostValues();
$edit['hostname'] = 'example.com';
$this
->drupalGet('admin/config/domain/add');
$this
->submitForm($edit, 'Save');
$default_id = $storage
->loadDefaultId();
$this
->assertNotEmpty($default_id, 'Domain record saved via form.');
$storage
->resetCache([
$default_id,
]);
$new_domain = $storage
->load($default_id);
$this
->assertTrue($new_domain
->id() == $default_id, 'Domain loaded properly.');
$this
->assertNotEmpty($new_domain
->uuid(), 'Entity UUID set properly.');
$editUrl = 'admin/config/domain/edit/' . $new_domain
->id();
$this
->drupalGet($editUrl);
$edit = [];
$edit['name'] = 'Foo';
$edit['validate_url'] = 0;
$this
->drupalGet($editUrl);
$this
->submitForm($edit, 'Save');
$storage
->resetCache([
$default_id,
]);
$domain = $storage
->load($default_id);
$this
->assertTrue($domain
->label() == 'Foo', 'Domain record updated via form.');
$deleteUrl = 'admin/config/domain/delete/' . $new_domain
->id();
$this
->drupalGet($deleteUrl);
$this
->drupalGet($deleteUrl);
$this
->submitForm([], 'Delete');
$storage
->resetCache([
$default_id,
]);
$domain = $storage
->load($default_id);
$this
->assertEmpty($domain, 'Domain record deleted.');
$this
->domainTableIsEmpty();
}
}