RedirectDomainUITest.php in Redirect 8
File
modules/redirect_domain/tests/src/FunctionalJavascript/RedirectDomainUITest.php
View source
<?php
namespace Drupal\Tests\redirect_domain\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class RedirectDomainUITest extends WebDriverTestBase {
public static $modules = [
'redirect_domain',
];
protected $defaultTheme = 'stark';
public function testDomainRedirect() {
$user = $this
->drupalCreateUser([
'administer site configuration',
'access administration pages',
'administer redirects',
]);
$this
->drupalLogin($user);
$this
->drupalGet('/admin/config/search/redirect/domain');
$this
->assertFieldByName('redirects[0][from]');
$this
->assertFieldByName('redirects[0][sub_path]');
$this
->assertFieldByName('redirects[0][destination]');
$page = $this
->getSession()
->getPage();
$page
->pressButton('Add another');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$page
->fillField('redirects[0][from]', 'foo.example.org');
$page
->fillField('redirects[0][sub_path]', '//sub-path');
$page
->fillField('redirects[0][destination]', 'www.example.org/foo');
$page
->fillField('redirects[1][from]', 'bar.example.org');
$page
->fillField('redirects[1][sub_path]', '');
$page
->fillField('redirects[1][destination]', 'www.example.org/bar');
$page
->pressButton('Save');
$this
->assertFieldByName('redirects[0][from]', 'foo.example.org');
$this
->assertFieldByName('redirects[0][destination]', 'www.example.org/foo');
$this
->assertFieldByName('redirects[1][from]', 'bar.example.org');
$this
->assertFieldByName('redirects[1][destination]', 'www.example.org/bar');
$this
->assertFieldByName('redirects[0][sub_path]', '/sub-path');
$this
->assertFieldByName('redirects[1][sub_path]', '/');
}
}