protected function setUp()
 {
     parent::setUp();
     // Set up an additional language.
     $this->langcodes = array(language_default()->getId(), 'es');
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Create a content type.
     $this->bundle = $this->randomMachineName();
     $this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
     // Enable translation for the current entity type and ensure the change is
     // picked up.
     content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedBundles();
     \Drupal::service('router.builder')->rebuild();
     // Add a translatable field to the content type.
     entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
     entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
     // Enable content translation.
     $configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
     language_save_default_configuration('node', $this->bundle, $configuration);
     // Create a translator user.
     $permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
     $this->translator = $this->drupalCreateUser($permissions);
 }
 /**
  * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupBundle().
  */
 function setupBundle()
 {
     parent::setupBundle();
     $this->drupalCreateContentType(array('type' => $this->nodeBundle, 'name' => $this->nodeBundle));
     // Add a comment field to the article content type.
     $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article');
     // Create a page content type.
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'page'));
     // Add a comment field to the page content type - this one won't be
     // translatable.
     $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment');
     // Mark this bundle as translatable.
     content_translation_set_config('comment', 'comment_article', 'enabled', TRUE);
 }
 /**
  * Tests that the taxonomy term view is working properly.
  */
 public function testTaxonomyTermView()
 {
     // Create terms in the vocabulary.
     $term = $this->createTerm($this->vocabulary);
     // Post an article.
     $edit = array();
     $edit['title[0][value]'] = $original_title = $this->randomMachineName();
     $edit['body[0][value]'] = $this->randomMachineName();
     $edit["{$this->field_name_1}[]"] = $term->id();
     $this->drupalPostForm('node/add/article', $edit, t('Save'));
     $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->drupalGet('taxonomy/term/' . $term->id());
     $this->assertText($term->label());
     $this->assertText($node->label());
     \Drupal::moduleHandler()->install(array('language', 'content_translation'));
     $language = ConfigurableLanguage::createFromLangcode('ur');
     $language->save();
     // Enable translation for the article content type and ensure the change is
     // picked up.
     content_translation_set_config('node', 'article', 'enabled', TRUE);
     $roles = $this->admin_user->getRoles(TRUE);
     Role::load(reset($roles))->grantPermission('create content translations')->grantPermission('translate any entity')->save();
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
     $edit['title[0][value]'] = $translated_title = $this->randomMachineName();
     $this->drupalPostForm('node/' . $node->id() . '/translations/add/en/ur', $edit, t('Save (this translation)'));
     $this->drupalGet('taxonomy/term/' . $term->id());
     $this->assertText($term->label());
     $this->assertText($original_title);
     $this->assertNoText($translated_title);
     $this->drupalGet('ur/taxonomy/term/' . $term->id());
     $this->assertText($term->label());
     $this->assertNoText($original_title);
     $this->assertText($translated_title);
 }
 /**
  * Enables translations where it needed.
  */
 protected function enableTranslation()
 {
     // Enable translation for the current entity type and ensure the change is
     // picked up.
     content_translation_set_config('node', 'article', 'enabled', TRUE);
     content_translation_set_config('taxonomy', $this->vocabulary->id(), 'enabled', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
 }
 /**
  * Enables translations where it needed.
  */
 protected function enableTranslation()
 {
     // Enable translation for the entity types and ensure the change is picked
     // up.
     content_translation_set_config($this->testEntityTypeName, $this->referrerType->id(), 'enabled', TRUE);
     content_translation_set_config($this->testEntityTypeName, $this->referencedType->id(), 'enabled', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
 }
 /**
  * Enables translation for the current entity type and bundle.
  */
 protected function enableTranslation()
 {
     // Enable translation for the current entity type and ensure the change is
     // picked up.
     content_translation_set_config($this->entityTypeId, $this->bundle, 'enabled', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
 }