function NodeAdminTest::testContentAdminPageMultilingual
Same name in other branches
- 10 core/modules/node/tests/src/Functional/NodeAdminTest.php \Drupal\Tests\node\Functional\NodeAdminTest::testContentAdminPageMultilingual()
Tests content overview for a multilingual site.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeAdminTest.php, line 241
Class
- NodeAdminTest
- Tests node administration page functionality.
Namespace
Drupal\Tests\node\FunctionalCode
public function testContentAdminPageMultilingual() : void {
$this->drupalLogin($this->adminUser);
\Drupal::service('module_installer')->install([
'language',
]);
ConfigurableLanguage::create([
'id' => 'es',
'label' => 'Spanish',
])->save();
$this->drupalCreateNode([
'type' => 'page',
'title' => 'English title',
])
->addTranslation('es')
->setTitle('Spanish title')
->save();
$this->drupalGet('admin/content');
// Ensure that both the language table column as well as the language
// exposed filter are visible on multilingual sites.
$this->assertSession()
->fieldExists('langcode');
$this->assertEquals(2, count($this->cssSelect('td.views-field-langcode')));
$this->assertEquals(2, count($this->cssSelect('td.views-field-langcode')));
$this->assertSession()
->pageTextContains('English title');
$this->assertSession()
->pageTextContains('Spanish title');
$this->drupalGet('admin/content', [
'query' => [
'langcode' => '***LANGUAGE_site_default***',
],
]);
$this->assertSession()
->pageTextContains('English title');
$this->assertSession()
->pageTextNotContains('Spanish title');
$this->drupalGet('admin/content', [
'query' => [
'langcode' => 'en',
],
]);
$this->assertSession()
->pageTextContains('English title');
$this->assertSession()
->pageTextNotContains('Spanish title');
$this->drupalGet('admin/content', [
'query' => [
'langcode' => 'und',
],
]);
$this->assertSession()
->pageTextNotContains('English title');
$this->assertSession()
->pageTextNotContains('Spanish title');
$this->drupalGet('admin/content', [
'query' => [
'langcode' => 'zxx',
],
]);
$this->assertSession()
->pageTextNotContains('English title');
$this->assertSession()
->pageTextNotContains('Spanish title');
$this->drupalGet('admin/content', [
'query' => [
'langcode' => html_entity_decode('***LANGUAGE_language_interface***'),
],
]);
$this->assertSession()
->pageTextContains('English title');
$this->assertSession()
->pageTextNotContains('Spanish title');
$this->drupalGet('es/admin/content', [
'query' => [
'langcode' => html_entity_decode('***LANGUAGE_language_interface***'),
],
]);
$this->assertSession()
->pageTextNotContains('English title');
$this->assertSession()
->pageTextContains('Spanish title');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.