DomainPathNodeAliasTest.php in Domain Path 8
File
tests/src/Functional/DomainPathNodeAliasTest.php
View source
<?php
namespace Drupal\Tests\domain_path\Functional;
class DomainPathNodeAliasTest extends DomainPathTestBase {
protected function setUp() {
parent::setUp();
}
public function testDomainPathNodeAliasesFill() {
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
foreach ($this->domains as $domain) {
$domain_specific_alias_value = $this
->randomMachineName(8);
$domain_specific_alias_path = "/{$domain_specific_alias_value}";
$edit['domain_path[' . $domain
->id() . ']'] = $domain_specific_alias_path;
if ($domain
->isDefault()) {
$domain_paths_check['default'] = $domain_specific_alias_value;
}
else {
$domain_paths_check['specific'] = $domain_specific_alias_value;
}
}
$edit['path[0][alias]'] = '/' . $this
->randomMachineName(8);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this
->drupalGetNodeByTitle($edit['title[0][value]']);
$this
->assertTrue($node, 'Node found in database.');
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertSession()
->statusCodeEquals(200);
if (!empty($domain_paths_check['default'])) {
$this
->drupalGet($domain_paths_check['default']);
$this
->assertSession()
->statusCodeEquals(200);
}
if (!empty($domain_paths_check['specific'])) {
$this
->drupalGet($domain_paths_check['specific']);
$this
->assertSession()
->statusCodeNotEquals(200);
}
}
}