function TermTranslationUITest::testTranslateLinkVocabularyAdminPage

Tests translate link on vocabulary term list.

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php, line 119
Definition of Drupal\taxonomy\Tests\TermTranslationUITest.

Class

TermTranslationUITest
Tests the Term Translation UI.

Namespace

Drupal\taxonomy\Tests

Code

function testTranslateLinkVocabularyAdminPage() {
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'access administration pages',
    'administer taxonomy',
    'translate any entity',
  ));
  $this
    ->drupalLogin($this->admin_user);
  $translatable_vocabulary_name = $this->vocabulary->name;
  $translatable_tid = $this
    ->createEntity(array(), $this->langcodes[0]);

  // Create an untranslatable vocabulary.
  $untranslatable_vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => 'untranslatable_voc',
    'description' => $this
      ->randomName(),
    'machine_name' => 'untranslatable_voc',
    'langcode' => LANGUAGE_NOT_SPECIFIED,
    'help' => '',
    'weight' => mt_rand(0, 10),
  ));
  $untranslatable_vocabulary
    ->save();
  $untranslatable_vocabulary_name = $untranslatable_vocabulary->name;
  $untranslatable_tid = $this
    ->createEntity(array(), $this->langcodes[0], $untranslatable_vocabulary_name);

  // Verify translation links.
  $this
    ->drupalGet('admin/structure/taxonomy/' . $translatable_vocabulary_name);
  $this
    ->assertResponse(200);
  $this
    ->assertLinkByHref('term/' . $translatable_tid . '/translations');
  $this
    ->assertLinkByHref('term/' . $translatable_tid . '/edit');
  $this
    ->drupalGet('admin/structure/taxonomy/' . $untranslatable_vocabulary_name);
  $this
    ->assertResponse(200);
  $this
    ->assertLinkByHref('term/' . $untranslatable_tid . '/edit');
  $this
    ->assertNoLinkByHref('term/' . $untranslatable_tid . '/translations');
}