3 namespace Drupal\Tests\content_translation\Functional\Views;
5 use Drupal\Tests\content_translation\Functional\ContentTranslationTestBase;
6 use Drupal\views\Tests\ViewTestData;
7 use Drupal\Core\Language\Language;
8 use Drupal\user\Entity\User;
11 * Tests the content translation overview link field handler.
13 * @group content_translation
14 * @see \Drupal\content_translation\Plugin\views\field\TranslationLink
16 class TranslationLinkTest extends ContentTranslationTestBase {
19 * Views used by this test.
23 public static $testViews = ['test_entity_translations_link'];
30 public static $modules = ['content_translation_test_views'];
32 protected function setUp() {
33 // @todo Use entity_type once it is has multilingual Views integration.
34 $this->entityTypeId = 'user';
38 // Assign user 1 a language code so that the entity can be translated.
39 $user = User::load(1);
40 $user->langcode = 'en';
43 // Assign user 2 LANGCODE_NOT_SPECIFIED code so entity can't be translated.
44 $user = User::load(2);
45 $user->langcode = Language::LANGCODE_NOT_SPECIFIED;
48 ViewTestData::createTestViews(get_class($this), ['content_translation_test_views']);
54 protected function getTranslatorPermissions() {
55 $permissions = parent::getTranslatorPermissions();
56 $permissions[] = 'access user profiles';
61 * Tests the content translation overview link field handler.
63 public function testTranslationLink() {
64 $this->drupalGet('test-entity-translations-link');
65 $this->assertLinkByHref('user/1/translations');
66 $this->assertNoLinkByHref('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.');