public function DomainSiteSettingsUiTest::testSettingsForm in Domain Site Settings 8
Test the settings form.
File
- tests/
src/ Functional/ DomainSiteSettingsUiTest.php, line 75
Class
- DomainSiteSettingsUiTest
- Tests UI pages.
Namespace
Drupal\Tests\domain_site_settings\FunctionalCode
public function testSettingsForm() {
// Create a new domain.
$domain = Domain::create([
'id' => 'foo',
'hostname' => 'foo.example.com',
'name' => 'Foo',
'scheme' => 'http',
]);
$domain
->save();
// The anonymous user doesn't have the permission to access this page.
$this
->drupalGet('admin/config/domain/domain_site_settings/foo/edit');
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/domain/domain_site_settings/foo/edit');
$this
->assertSession()
->statusCodeEquals(200);
// Save the form and check if the values are correctly stored in config.
$this
->submitForm([
'site_name' => 'Site name',
'site_slogan' => 'Slogan',
'site_mail' => 'sitemail@example.com',
'site_frontpage' => '/user',
'site_403' => '/user?404',
'site_404' => '/user?403',
], 'Save configuration');
$config = $this
->config('domain_site_settings.domainconfigsettings');
$this
->assertEquals('Site name', $config
->get('foo.site_name'));
$this
->assertEquals('Slogan', $config
->get('foo.site_slogan'));
$this
->assertEquals('sitemail@example.com', $config
->get('foo.site_mail'));
$this
->assertEquals('/user', $config
->get('foo.site_frontpage'));
$this
->assertEquals('/user?404', $config
->get('foo.site_403'));
$this
->assertEquals('/user?403', $config
->get('foo.site_404'));
}