Exemplo n.º 1
0
 protected function doTestBasicTranslation()
 {
     parent::doTestBasicTranslation();
     $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
     foreach ($this->langcodes as $langcode) {
         if ($entity->hasTranslation($langcode)) {
             $language = new Language(array('id' => $langcode));
             // Request the front page in this language and assert that the right
             // translation shows up in the shortcut list with the right path.
             $this->drupalGet('<front>', array('language' => $language));
             $expected_path = \Drupal::urlGenerator()->generateFromRoute('user.page', array(), array('language' => $language));
             $label = $entity->getTranslation($langcode)->label();
             $elements = $this->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="toolbar-menu"]/li/a[contains(@href, :href) and normalize-space(text())=:label]', array(':href' => $expected_path, ':label' => $label));
             $this->assertTrue(!empty($elements), format_string('Translated @language shortcut link @label found.', array('@label' => $label, '@language' => $language->getName())));
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 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');
 }