public function DomainSourceElementTest::testAnonForm in Domain Access 8
Test for https://www.drupal.org/project/domain/issues/3010256.
File
- domain_source/
tests/ src/ Functional/ DomainSourceElementTest.php, line 149
Class
- DomainSourceElementTest
- Tests behavior for the domain source field element.
Namespace
Drupal\Tests\domain_source\FunctionalCode
public function testAnonForm() {
// Editor with no domain permissions should not see the element.
$editor = $this
->drupalCreateUser([
'create article content',
]);
$this
->drupalLogin($editor);
$this
->drupalGet('node/add/article');
$this
->assertSession()
->statusCodeEquals(200);
$locator = DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD;
$this
->assertSession()
->fieldNotExists($locator);
// Editor with domain permissions should see the element once they
// are assigned to domains.
$editor2 = $this
->drupalCreateUser([
'create article content',
'publish to any assigned domain',
]);
$this
->drupalLogin($editor2);
$this
->drupalGet('node/add/article');
$this
->assertSession()
->statusCodeEquals(200);
$locator = DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD;
$this
->assertSession()
->fieldNotExists($locator);
// Domain assignment.
$ids = [
'example_com',
'one_example_com',
];
$this
->addDomainsToEntity('user', $editor2
->id(), $ids, DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD);
$this
->drupalGet('node/add/article');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldExists($locator);
}