public function LanguageSelectionPageConditionTest::testIgnoreLanguageNeutral in Language Selection Page 8.2
Test the "ignore language neutral" condition.
File
- tests/
src/ Functional/ LanguageSelectionPageConditionTest.php, line 189
Class
- LanguageSelectionPageConditionTest
- Tests that the condition plugins work.
Namespace
Drupal\Tests\language_selection_page\FunctionalCode
public function testIgnoreLanguageNeutral() {
// Enable ignore language paths.
$this
->drupalPostForm('admin/config/regional/language/detection/language_selection_page', [
'ignore_neutral' => 1,
], 'Save configuration');
// Create translatable node.
$translatable_node1 = $this
->drupalCreateNode([
'langcode' => 'fr',
]);
$this
->drupalGet('node/' . $translatable_node1
->id());
$this
->assertLanguageSelectionPageLoaded();
// Create untranslatable node.
$untranslatable_node1 = $this
->drupalCreateNode([
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$this
->drupalGet('node/' . $untranslatable_node1
->id());
$this
->assertLanguageSelectionPageNotLoaded();
// Create untranslatable node.
$untranslatable_node1 = $this
->drupalCreateNode([
'langcode' => LanguageInterface::LANGCODE_NOT_APPLICABLE,
]);
$this
->drupalGet('node/' . $untranslatable_node1
->id());
$this
->assertLanguageSelectionPageNotLoaded();
// Turn off translatability of the content type.
$this
->drupalPostform('admin/structure/types/manage/page', [
'language_configuration[content_translation]' => 0,
], 'Save content type');
$this
->drupalGet('node/' . $translatable_node1
->id());
// Assert that we don't redirect anymore.
$this
->assertLanguageSelectionPageNotLoaded();
// Turn on translatability of the content type.
$this
->drupalPostform('admin/structure/types/manage/page', [
'language_configuration[content_translation]' => 1,
], 'Save content type');
// Disable ignore language paths.
$this
->drupalPostForm('admin/config/regional/language/detection/language_selection_page', [
'ignore_neutral' => 0,
], 'Save configuration');
$this
->drupalGet('node/' . $untranslatable_node1
->id());
$this
->assertLanguageSelectionPageLoaded();
$this
->resetConfiguration();
}