You are here

protected function BlockContentTranslationUITest::doTestBasicTranslation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block_content/src/Tests/BlockContentTranslationUITest.php \Drupal\block_content\Tests\BlockContentTranslationUITest::doTestBasicTranslation()

Tests the basic translation workflow.

Overrides ContentTranslationUITestBase::doTestBasicTranslation

File

core/modules/block_content/src/Tests/BlockContentTranslationUITest.php, line 132
Contains \Drupal\block_content\Tests\BlockContentTranslationUITest.

Class

BlockContentTranslationUITest
Tests the block content translation UI.

Namespace

Drupal\block_content\Tests

Code

protected function doTestBasicTranslation() {
  parent::doTestBasicTranslation();

  // Ensure that a block translation can be created using the same description
  // as in the original language.
  $default_langcode = $this->langcodes[0];
  $values = $this
    ->getNewEntityValues($default_langcode);
  $storage = \Drupal::entityManager()
    ->getStorage($this->entityTypeId);

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $storage
    ->create(array(
    'type' => 'basic',
  ) + $values);
  $entity
    ->save();
  $entity
    ->addTranslation('it', $values);
  try {
    $message = 'Blocks can have translations with the same "info" value.';
    $entity
      ->save();
    $this
      ->pass($message);
  } catch (\Exception $e) {
    $this
      ->fail($message);
  }

  // Check that the translate operation link is shown.
  $this
    ->drupalGet('admin/structure/block/block-content');
  $this
    ->assertLinkByHref('block/' . $entity
    ->id() . '/translations');
}