コード例 #1
0
 /**
  * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupBundle().
  */
 protected function setupBundle()
 {
     parent::setupBundle();
     // Create a vocabulary.
     $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->bundle, 'description' => $this->randomName(), 'vid' => $this->bundle, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10)));
     $this->vocabulary->save();
 }
コード例 #2
0
ファイル: FastTestBase.php プロジェクト: darrylri/protovbmwmo
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('system_breadcrumb_block');
     $this->drupalPlaceBlock('local_tasks_block');
     // Create a test user.
     $this->adminUser = $this->drupalCreateUser(array('access content', 'admin classes', 'admin display suite', 'admin fields', 'administer nodes', 'view all revisions', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer permissions', 'administer account settings', 'administer user display', 'administer software updates', 'access site in maintenance mode', 'administer site configuration', 'bypass node access', 'ds switch view mode'));
     $this->drupalLogin($this->adminUser);
     // Create random field name.
     $this->fieldLabel = $this->randomMachineName(8);
     $this->fieldNameInput = strtolower($this->randomMachineName(8));
     $this->fieldName = 'field_' . $this->fieldNameInput;
     // Create Article node type.
     $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article', 'revision' => TRUE));
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page', 'revision' => TRUE));
     // Create a vocabulary named "Tags".
     $this->vocabulary = Vocabulary::create(array('name' => 'Tags', 'vid' => 'tags', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->vocabulary->save();
     $term1 = Term::create(array('name' => 'Tag 1', 'vid' => 'tags', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $term1->save();
     $term2 = Term::create(array('name' => 'Tag 2', 'vid' => 'tags', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $term2->save();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', 'field_' . $this->vocabulary->id(), 'Tags', 'taxonomy_term', 'default', $handler_settings, 10);
     entity_get_form_display('node', 'article', 'default')->setComponent('field_' . $this->vocabulary->id())->save();
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setup();
     $this->installEntitySchema('node');
     $this->installEntitySchema('taxonomy_term');
     $this->installEntitySchema('entity_test');
     $this->nodeType = NodeType::create(['type' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomString()]);
     $this->nodeType->save();
     $this->vocabulary = Vocabulary::create(['vid' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomString()]);
     $this->vocabulary->save();
     // Create a custom bundle.
     $this->customBundle = 'test_bundle_' . Unicode::strtolower($this->randomMachineName());
     entity_test_create_bundle($this->customBundle, NULL, 'entity_test');
 }