/**
  * {@inheritdoc}
  */
 protected function createEntity($values, $langcode, $bundle_name = NULL)
 {
     $values['menu_name'] = 'tools';
     $values['route_name'] = 'menu_ui.overview_page';
     $values['title'] = 'Test title';
     return parent::createEntity($values, $langcode, $bundle_name);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function createEntity($values, $langcode, $bundle_name = NULL)
 {
     $values['menu_name'] = 'tools';
     $values['link']['uri'] = 'internal:/admin/structure/menu';
     $values['title'] = 'Test title';
     return parent::createEntity($values, $langcode, $bundle_name);
 }
 /**
  * Returns an edit array containing the values to be posted.
  */
 protected function getEditValues($values, $langcode, $new = FALSE)
 {
     $edit = parent::getEditValues($values, $langcode, $new);
     foreach ($edit as $property => $value) {
         if ($property == 'info') {
             $edit['info[0][value]'] = $value;
             unset($edit[$property]);
         }
     }
     return $edit;
 }
 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="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())));
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Tests translate link on vocabulary term list.
  */
 function testTranslateLinkVocabularyAdminPage()
 {
     $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer taxonomy')));
     $this->drupalLogin($this->admin_user);
     $values = array('name' => $this->randomName());
     $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->randomName(), 'vid' => 'untranslatable_voc', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10)));
     $untranslatable_vocabulary->save();
     $values = array('name' => $this->randomName());
     $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');
 }
 /**
  * {@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);
     }
 }
Ejemplo n.º 7
0
 /**
  * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues().
  */
 protected function getNewEntityValues($langcode)
 {
     return array('title' => array(array('value' => $this->randomName()))) + parent::getNewEntityValues($langcode);
 }
Ejemplo n.º 8
0
 /**
  * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues().
  */
 protected function getNewEntityValues($langcode)
 {
     // User name is not translatable hence we use a fixed value.
     return array('name' => $this->name) + parent::getNewEntityValues($langcode);
 }
 /**
  * Tests translate link on comment content admin page.
  */
 function testTranslateLinkCommentAdminPage()
 {
     $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments', 'skip comment approval')));
     $this->drupalLogin($this->admin_user);
     $cid_translatable = $this->createEntity(array(), $this->langcodes[0]);
     $cid_untranslatable = $this->createEntity(array(), $this->langcodes[0], 'comment');
     // Verify translation links.
     $this->drupalGet('admin/content/comment');
     $this->assertResponse(200);
     $this->assertLinkByHref('comment/' . $cid_translatable . '/translations');
     $this->assertNoLinkByHref('comment/' . $cid_untranslatable . '/translations');
 }