ContentTranslationContextualLinksTest.php in Drupal 10
File
core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php
View source
<?php
namespace Drupal\Tests\content_translation\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
class ContentTranslationContextualLinksTest extends WebDriverTestBase {
protected $translator;
protected static $modules = [
'content_translation',
'contextual',
'node',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::createFromLangcode('es')
->save();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/config/regional/content-language');
$edit = [
'entity_types[node]' => TRUE,
'settings[node][page][translatable]' => TRUE,
];
$this
->submitForm($edit, 'Save configuration');
$this
->drupalLogout();
$permissions = [
'access contextual links',
'administer nodes',
'edit any page content',
'translate any entity',
];
$this->translator = $this
->drupalCreateUser($permissions);
}
public function testContentTranslationContextualLinks() {
$node = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'Test',
]);
$this
->drupalLogin($this->translator);
$this
->drupalGet('node/' . $node
->id());
$link = $this
->assertSession()
->waitForElement('css', '[data-contextual-id^="node:node=1"] .contextual-links a:contains("Translate")');
$this
->assertStringContainsString('node/1/translations', $link
->getAttribute('href'));
}
}