public function DomainConfigUIOverrideTest::testAjax in Domain Access 8
Tests that we can save domain and language-specific settings.
File
- domain_config_ui/
tests/ src/ FunctionalJavascript/ DomainConfigUIOverrideTest.php, line 66
Class
- DomainConfigUIOverrideTest
- Tests the domain config user interface.
Namespace
Drupal\Tests\domain_config_ui\FunctionalJavascriptCode
public function testAjax() {
// Test base configuration.
$config_name = 'system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'Drupal');
$this
->assertEquals($config['page']['front'], '/user/login');
// Test stored configuration.
$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';
// Visit the site information page.
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
// Test our form.
$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());
// We did not save a language prefix, so none will be present.
$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');
// Now let's save a language.
// Visit the site information page.
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
// Test our form.
$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());
// We did save a language prefix, so one will be present.
$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');
// Make sure the base is untouched.
$config_name = 'system.site';
$config = \Drupal::configFactory()
->get($config_name)
->getRawData();
$this
->assertEquals($config['name'], 'Drupal');
$this
->assertEquals($config['page']['front'], '/user/login');
}