class NodeViewLanguageTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Functional/NodeViewLanguageTest.php \Drupal\Tests\node\Functional\NodeViewLanguageTest
- 9 core/modules/node/tests/src/Functional/NodeViewLanguageTest.php \Drupal\Tests\node\Functional\NodeViewLanguageTest
Tests the node language extra field display.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeViewLanguageTest
- class \Drupal\Tests\node\Functional\NodeTestBase
Expanded class hierarchy of NodeViewLanguageTest
File
- core/
modules/ node/ tests/ src/ Functional/ NodeViewLanguageTest.php, line 12
Namespace
Drupal\Tests\node\FunctionalView source
class NodeViewLanguageTest extends NodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
'datetime',
'language',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the language extra field display.
*/
public function testViewLanguage() {
// Add Spanish language.
ConfigurableLanguage::createFromLangcode('es')
->save();
// Set language field visible.
\Drupal::service('entity_display.repository')
->getViewDisplay('node', 'page', 'full')
->setComponent('langcode')
->save();
// Create a node in Spanish.
$node = $this
->drupalCreateNode([
'langcode' => 'es',
]);
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextContains('Spanish');
}
}