DomainConfigUiSavedConfigTest.php in Domain Access 8
File
domain_config_ui/tests/src/FunctionalJavascript/DomainConfigUiSavedConfigTest.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 DomainConfigUiSavedConfigTest extends WebDriverTestBase {
use DomainConfigUITestTrait;
use DomainTestTrait;
protected $strictConfigSchema = FALSE;
protected $defaultTheme = 'stable';
public static $modules = [
'domain_config_ui',
'language',
];
public function setUp() {
parent::setUp();
$this
->createAdminUser();
$this
->createEditorUser();
$this
->setBaseHostname();
$this
->domainCreateTestDomains(5);
$this
->createLanguage();
}
public function testSavedConfig() {
$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());
$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());
$path = '/admin/config/domain/config-ui/list';
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$this
->htmlOutput($page
->getHtml());
$this
->assertSession()
->pageTextContains('Saved configuration');
$this
->assertSession()
->pageTextContains('domain.config.one_example_com.system.site');
$this
->assertSession()
->pageTextContains('domain.config.one_example_com.es.system.site');
$this
->assertSession()
->pageTextNotContains('domain.config.example_com.en.system.site');
$page
->findLink('Inspect');
$page
->clickLink('Inspect');
$page = $this
->getSession()
->getPage();
$this
->htmlOutput($page
->getHtml());
$this
->assertSession()
->pageTextContains('domain.config.one_example_com.es.system.site');
$this
->assertSession()
->pageTextContains('Neuvo nombre');
$path = '/admin/config/domain/config_ui/inspect/domain.config.one_example_com.system.site';
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$this
->htmlOutput($page
->getHtml());
$this
->assertSession()
->pageTextContains('domain.config.one_example_com.system.site');
$this
->assertSession()
->pageTextContains('New name');
$path = '/admin/config/domain/config_ui/delete/domain.config.one_example_com.system.site';
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$this
->htmlOutput($page
->getHtml());
$this
->assertSession()
->pageTextContains('Are you sure you want to delete the configuration override: domain.config.one_example_com.system.site?');
$page
->findButton('Delete configuration');
$page
->pressButton('Delete configuration');
$path = '/admin/config/domain/config-ui/list';
$this
->drupalGet($path);
$page = $this
->getSession()
->getPage();
$this
->htmlOutput($page
->getHtml());
$this
->assertSession()
->pageTextContains('Saved configuration');
$this
->assertSession()
->pageTextNotContains('domain.config.one_example_com.system.site');
$this
->assertSession()
->pageTextContains('domain.config.one_example_com.es.system.site');
$this
->assertSession()
->pageTextNotContains('domain.config.example_com.en.system.site');
}
private function createLanguage() {
$adminUser = $this
->drupalCreateUser([
'administer languages',
'access administration pages',
]);
$this
->drupalLogin($adminUser);
$edit = [
'predefined_langcode' => 'es',
];
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
$edit = [
'language_interface[enabled][language-url]' => '1',
];
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm($edit, 'Save settings');
$this
->drupalLogout();
$this
->rebuildContainer();
$es = \Drupal::entityTypeManager()
->getStorage('configurable_language')
->load('es');
$this
->assertTrue(!empty($es), 'Created test language.');
}
}