DomainConfigUIOverrideTest.php in Domain Access 8
File
domain_config_ui/tests/src/FunctionalJavascript/DomainConfigUIOverrideTest.php
View source
<?php
namespace Drupal\Tests\domain_config_ui\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\domain_config_ui\Traits\DomainConfigUITestTrait;
use Drupal\Tests\domain\Traits\DomainTestTrait;
class DomainConfigUIOverrideTest extends WebDriverTestBase {
use DomainConfigUITestTrait;
use DomainTestTrait;
protected $strictConfigSchema = FALSE;
protected $defaultTheme = 'stable';
public static $modules = [
'domain_config_ui',
'domain_config_test',
'language',
];
public function setUp() {
parent::setUp();
$this
->createAdminUser();
$this
->createEditorUser();
$this
->setBaseHostname();
$this
->domainCreateTestDomains(5);
$this
->createLanguage();
}
public function testAjax() {
$config_name = 'system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'Drupal');
$this
->assertEquals($config['page']['front'], '/user/login');
$config_name = 'domain.config.one_example_com.en.system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'One');
$this
->assertEquals($config['page']['front'], '/node/1');
$this
->drupalLogin($this->adminUser);
$path = '/admin/config/system/site-information';
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$page
->findField('domain');
$page
->findField('language');
$page
->selectFieldOption('domain', 'one_example_com');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput($page
->getHtml());
$page = $this
->getSession()
->getPage();
$page
->fillField('site_name', 'New name');
$page
->fillField('site_frontpage', '/user');
$this
->htmlOutput($page
->getHtml());
$page
->pressButton('Save configuration');
$this
->htmlOutput($page
->getHtml());
$config_name = 'domain.config.one_example_com.system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'New name');
$this
->assertEquals($config['page']['front'], '/user');
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$page
->selectFieldOption('domain', 'one_example_com');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput($page
->getHtml());
$page = $this
->getSession()
->getPage();
$page
->selectFieldOption('language', 'es');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->htmlOutput($page
->getHtml());
$page = $this
->getSession()
->getPage();
$page
->fillField('site_name', 'Neuvo nombre');
$page
->fillField('site_frontpage', '/user');
$this
->htmlOutput($page
->getHtml());
$page
->pressButton('Save configuration');
$this
->htmlOutput($page
->getHtml());
$config_name = 'domain.config.one_example_com.es.system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'Neuvo nombre');
$this
->assertEquals($config['page']['front'], '/user');
$config_name = 'system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'Drupal');
$this
->assertEquals($config['page']['front'], '/user/login');
}
}