function BlockContentTranslationUITest::doTestBasicTranslation

Same name in other branches
  1. 9 core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php \Drupal\Tests\block_content\Functional\BlockContentTranslationUITest::doTestBasicTranslation()
  2. 10 core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php \Drupal\Tests\block_content\Functional\BlockContentTranslationUITest::doTestBasicTranslation()
  3. 11.x core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php \Drupal\Tests\block_content\Functional\BlockContentTranslationUITest::doTestBasicTranslation()

Overrides ContentTranslationUITestBase::doTestBasicTranslation

File

core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php, line 134

Class

BlockContentTranslationUITest
Tests the block content translation UI.

Namespace

Drupal\Tests\block_content\Functional

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::entityTypeManager()->getStorage($this->entityTypeId);
    
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $storage->create([
        'type' => 'basic',
    ] + $values);
    $entity->save();
    $entity->addTranslation('it', $values);
    try {
        $entity->save();
    } catch (\Exception $e) {
        $this->fail('Blocks can have translations with the same "info" value.');
    }
    // Check that the translate operation link is shown.
    $this->drupalGet('admin/structure/block/block-content');
    $this->assertLinkByHref('block/' . $entity->id() . '/translations');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.