class TranslationLinkTest
Same name and namespace in other branches
- 11.x core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php \Drupal\Tests\content_translation\Functional\Views\TranslationLinkTest
- 10 core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php \Drupal\Tests\content_translation\Functional\Views\TranslationLinkTest
Tests the content translation overview link field handler.
@group content_translation
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\content_translation\Functional\ContentTranslationTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\content_translation\Functional\Views\TranslationLinkTest implements \Drupal\Tests\content_translation\Functional\ContentTranslationTestBase
- class \Drupal\Tests\content_translation\Functional\ContentTranslationTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of TranslationLinkTest
See also
\Drupal\content_translation\Plugin\views\field\TranslationLink
File
-
core/
modules/ content_translation/ tests/ src/ Functional/ Views/ TranslationLinkTest.php, line 16
Namespace
Drupal\Tests\content_translation\Functional\ViewsView source
class TranslationLinkTest extends ContentTranslationTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_entity_translations_link',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'content_translation_test_views',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
// @todo Use entity_type once it has multilingual Views integration.
$this->entityTypeId = 'user';
parent::setUp();
// Assign user 1 a language code so that the entity can be translated.
$user = User::load(1);
$user->langcode = 'en';
$user->save();
// Assign user 2 LANGCODE_NOT_SPECIFIED code so entity can't be translated.
$user = User::load(2);
$user->langcode = Language::LANGCODE_NOT_SPECIFIED;
$user->save();
ViewTestData::createTestViews(static::class, [
'content_translation_test_views',
]);
}
/**
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
$permissions = parent::getTranslatorPermissions();
$permissions[] = 'access user profiles';
return $permissions;
}
/**
* Tests the content translation overview link field handler.
*/
public function testTranslationLink() {
$this->drupalGet('test-entity-translations-link');
$this->assertSession()
->linkByHrefExists('user/1/translations');
$this->assertSession()
->linkByHrefNotExists('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.