You are here

function TermTranslationUITest::testTranslateLinkVocabularyAdminPage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/TermTranslationUITest.php \Drupal\taxonomy\Tests\TermTranslationUITest::testTranslateLinkVocabularyAdminPage()

Tests translate link on vocabulary term list.

File

core/modules/taxonomy/src/Tests/TermTranslationUITest.php, line 107
Contains \Drupal\taxonomy\Tests\TermTranslationUITest.

Class

TermTranslationUITest
Tests the Term Translation UI.

Namespace

Drupal\taxonomy\Tests

Code

function testTranslateLinkVocabularyAdminPage() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), [
    'access administration pages',
    'administer taxonomy',
  ])));
  $values = array(
    'name' => $this
      ->randomMachineName(),
  );
  $translatable_tid = $this
    ->createEntity($values, $this->langcodes[0], $this->vocabulary
    ->id());

  // Create an untranslatable vocabulary.
  $untranslatable_vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => 'untranslatable_voc',
    'description' => $this
      ->randomMachineName(),
    'vid' => 'untranslatable_voc',
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    'weight' => mt_rand(0, 10),
  ));
  $untranslatable_vocabulary
    ->save();
  $values = array(
    'name' => $this
      ->randomMachineName(),
  );
  $untranslatable_tid = $this
    ->createEntity($values, $this->langcodes[0], $untranslatable_vocabulary
    ->id());

  // Verify translation links.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/overview');
  $this
    ->assertResponse(200, 'The translatable vocabulary page was found.');
  $this
    ->assertLinkByHref('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.');
  $this
    ->assertLinkByHref('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.');
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $untranslatable_vocabulary
    ->id() . '/overview');
  $this
    ->assertResponse(200);
  $this
    ->assertLinkByHref('term/' . $untranslatable_tid . '/edit');
  $this
    ->assertNoLinkByHref('term/' . $untranslatable_tid . '/translations');
}