TranslationLinkTest.php in Zircon Profile 8.0
File
core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php
View source
<?php
namespace Drupal\content_translation\Tests\Views;
use Drupal\content_translation\Tests\ContentTranslationTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\Core\Language\Language;
use Drupal\user\Entity\User;
class TranslationLinkTest extends ContentTranslationTestBase {
public static $testViews = array(
'test_entity_translations_link',
);
public static $modules = array(
'content_translation_test_views',
);
protected function setUp() {
$this->entityTypeId = 'user';
parent::setUp();
$user = User::load(1);
$user->langcode = 'en';
$user
->save();
$user = User::load(2);
$user->langcode = Language::LANGCODE_NOT_SPECIFIED;
$user
->save();
ViewTestData::createTestViews(get_class($this), array(
'content_translation_test_views',
));
}
protected function getTranslatorPermissions() {
$permissions = parent::getTranslatorPermissions();
$permissions[] = 'access user profiles';
return $permissions;
}
public function testTranslationLink() {
$this
->drupalGet('test-entity-translations-link');
$this
->assertLinkByHref('user/1/translations');
$this
->assertNoLinkByHref('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.');
}
}