public function GlobalRedirectTest::testLanguageRedirects in Redirect 8
Test that redirects work properly with content_translation enabled.
File
- tests/
src/ Functional/ GlobalRedirectTest.php, line 256
Class
- GlobalRedirectTest
- Global redirect test cases.
Namespace
Drupal\Tests\redirect\FunctionalCode
public function testLanguageRedirects() {
$this
->drupalLogin($this->adminUser);
// Add a new language.
ConfigurableLanguage::createFromLangcode('es')
->save();
// Enable URL language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => '1',
];
$this
->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Set page content type to use multilingual support.
$edit = [
'language_configuration[language_alterable]' => TRUE,
'language_configuration[content_translation]' => TRUE,
];
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this
->assertRaw(t('The content type %type has been updated.', [
'%type' => 'Page',
]));
$spanish_node = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'Spanish Test Page Node',
'path' => [
'alias' => '/spanish-test-node',
],
'langcode' => 'es',
]);
// Test multilingual redirect.
$this
->assertRedirect('es/node/' . $spanish_node
->id(), 'es/spanish-test-node');
}