View source
<?php
namespace Drupal\Tests\domain_config_ui\Functional;
use Drupal\domain\DomainInterface;
use Drupal\Tests\domain_config\Functional\DomainConfigTestBase;
use Drupal\Tests\domain_config_ui\Traits\DomainConfigUITestTrait;
class DomainConfigUIOptionsTest extends DomainConfigTestBase {
use DomainConfigUITestTrait;
public static $modules = [
'domain_config_ui',
];
public function setUp() {
parent::setUp();
$this
->createAdminUser();
$this
->createLimitedUser();
$this
->createLanguageUser();
$this
->domainCreateTestDomains(5);
$this
->addDomainsToEntity('user', $this->limitedUser
->id(), [
'example_com',
'one_example_com',
], DomainInterface::DOMAIN_ADMIN_FIELD);
$this
->addDomainsToEntity('user', $this->languageUser
->id(), [
'two_example_com',
'three_example_com',
], DomainInterface::DOMAIN_ADMIN_FIELD);
}
public function testFormOptions() {
$this
->drupalLogin($this->adminUser);
$path = '/admin/config/domain/config-ui';
$path2 = '/admin/config/system/site-information';
$this
->drupalGet($path);
$this
->assertResponse(200);
$this
->drupalGet($path2);
$this
->assertResponse(200);
$this
->findField('domain');
$this
->findField('language');
$domains = \Drupal::entityTypeManager()
->getStorage('domain')
->loadMultiple();
foreach ($domains as $domain) {
$string = 'value="' . $domain
->id() . '"';
$this
->assertRaw($string, 'Found the domain option.');
}
$this
->assertRaw('All Domains</option>', 'Found the domain option.');
$languages = [
'en',
'es',
];
foreach ($languages as $langcode) {
$string = 'value="' . $langcode . '"';
$this
->assertRaw($string, 'Found the language option.');
}
$this
->drupalLogin($this->limitedUser);
$this
->drupalGet($path);
$this
->assertResponse(403);
$this
->drupalGet($path2);
$this
->assertResponse(200);
$this
->findField('domain');
$this
->findNoField('language');
foreach ($domains as $domain) {
$string = 'value="' . $domain
->id() . '"';
if (in_array($domain
->id(), [
'example_com',
'one_example_com',
], TRUE)) {
$this
->assertRaw($string, 'Found the domain option.');
}
else {
$this
->assertNoRaw($string, 'Did not find the domain option.');
}
}
$this
->assertRaw('All Domains</option>', 'Found the domain option.');
$this
->drupalLogin($this->languageUser);
$this
->drupalGet($path);
$this
->assertResponse(403);
$this
->drupalGet($path2);
$this
->assertResponse(200);
$this
->findField('domain');
$this
->findField('language');
foreach ($domains as $domain) {
$string = 'value="' . $domain
->id() . '"';
if (in_array($domain
->id(), [
'two_example_com',
'three_example_com',
], TRUE)) {
$this
->assertRaw($string, 'Found the domain option.');
}
else {
$this
->assertNoRaw($string, 'Did not find the domain option.');
}
}
$this
->assertNoRaw('All Domains</option>', 'Found the domain option.');
$languages = [
'en',
'es',
];
foreach ($languages as $langcode) {
$string = 'value="' . $langcode . '"';
$this
->assertRaw($string, 'Found the language option.');
}
}
}