Example #1
0
 function setUp()
 {
     parent::setUp();
     $this->admin_user = $this->drupalCreateUser(array('administer taxonomy'));
     $this->drupalLogin($this->admin_user);
     $this->vocabulary = $this->createVocabulary();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
     $this->vocabulary = $this->createVocabulary();
     $this->drupalPlaceBlock('local_actions_block');
 }
 protected function setUp()
 {
     parent::setUp();
     $this->vocabulary = $this->createVocabulary();
     // RDF mapping - term bundle.
     rdf_get_mapping('taxonomy_term', $this->vocabulary->id())->setBundleMapping(array('types' => array('skos:Concept')))->setFieldMapping('name', array('properties' => array('rdfs:label', 'skos:prefLabel')))->save();
 }
Example #4
0
 protected function setUp()
 {
     parent::setUp();
     $admin_user = $this->drupalCreateUser(array('create article content', 'administer taxonomy'));
     $this->drupalLogin($admin_user);
     $this->vocabulary = $this->createVocabulary();
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setupLanguages();
     $this->vocabulary = $this->createVocabulary();
     $this->enableTranslation();
     $this->setUpTerms();
     $this->setUpTermReferenceField();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
     // Add some custom languages.
     ConfigurableLanguage::create(array('id' => 'aa', 'label' => $this->randomMachineName()))->save();
     ConfigurableLanguage::create(array('id' => 'bb', 'label' => $this->randomMachineName()))->save();
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create filter format.
     $restricted_html_format = entity_create('filter_format', array('format' => 'restricted_html', 'name' => 'Restricted HTML', 'filters' => array('filter_html' => array('status' => TRUE, 'weight' => -10, 'settings' => array('allowed_html' => '<p> <br /> <strong> <a> <em> <h4>')), 'filter_autop' => array('status' => TRUE, 'weight' => 0), 'filter_url' => array('status' => TRUE, 'weight' => 0), 'filter_htmlcorrector' => array('status' => TRUE, 'weight' => 10))));
     $restricted_html_format->save();
     // Create user then login.
     $this->user = $this->drupalCreateUser(array('administer site configuration', 'access site map', 'administer menu', 'administer nodes', 'create article content', 'administer taxonomy', $restricted_html_format->getPermissionName()));
     $this->drupalLogin($this->user);
 }
Example #8
0
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access', 'administer content types', 'administer node display']));
     $this->vocabulary = $this->createVocabulary();
     $this->fieldName = 'taxonomy_' . $this->vocabulary->id();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
     $this->vocabulary = $this->createVocabulary();
     $this->fieldName = 'taxonomy_' . $this->vocabulary->id();
     entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_config', array('field_name' => $this->fieldName, 'bundle' => 'article', 'entity_type' => 'node'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->fieldName, array('type' => 'taxonomy_term_reference_link'))->save();
 }
Example #10
0
 protected function setUp()
 {
     parent::setUp();
     // Create a tags vocabulary for the 'article' content type.
     $vocabulary = Vocabulary::create(['name' => 'Tags', 'vid' => 'tags']);
     $vocabulary->save();
     $field_name = 'field_' . $vocabulary->id();
     $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'entity_reference_autocomplete_tags'))->save();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access']));
 }
Example #11
0
 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
     // Create a vocabulary to which the terms will be assigned.
     $this->vocabulary = $this->createVocabulary();
     // Add some custom languages.
     foreach (array('aa', 'bb', 'cc') as $language_code) {
         ConfigurableLanguage::create(array('id' => $language_code, 'label' => $this->randomMachineName()))->save();
     }
 }
 function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->admin_user = $this->drupalCreateUser(array('administer taxonomy'));
     $this->drupalLogin($this->admin_user);
     // Add some custom languages.
     $language = new Language(array('id' => 'aa', 'name' => $this->randomMachineName()));
     language_save($language);
     $language = new Language(array('id' => 'bb', 'name' => $this->randomMachineName()));
     language_save($language);
 }
Example #13
0
 protected function setUp()
 {
     parent::setUp();
     // Create a tags vocabulary for the 'article' content type.
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Tags', 'vid' => 'tags'));
     $vocabulary->save();
     $field_name = 'field_' . $vocabulary->id();
     entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => $field_name, 'bundle' => 'article', 'label' => 'Tags'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'taxonomy_autocomplete'))->save();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access']));
 }
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['view test entity', 'administer entity_test content', 'administer taxonomy']));
     $this->vocabulary1 = $this->createVocabulary();
     $this->vocabulary2 = $this->createVocabulary();
     // Set up a field storage and a field.
     $this->fieldName = Unicode::strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary1->id(), 'parent' => '0'), array('vocabulary' => $this->vocabulary2->id(), 'parent' => '0')))))->save();
     entity_create('field_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'bundle' => 'entity_test'))->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($this->fieldName, array('type' => 'options_select'))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($this->fieldName, array('type' => 'taxonomy_term_reference_link'))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy'));
     $this->drupalLogin($web_user);
     $this->vocabulary = $this->createVocabulary();
     // Create the field.
     $this->fieldName = 'field_taxonomy_test';
     $this->createTaxonomyTermReferenceField($this->fieldName, $this->vocabulary);
     // Set the RDF mapping for the new field.
     rdf_get_mapping('node', 'article')->setFieldMapping($this->fieldName, array('properties' => array('dc:subject'), 'mapping_type' => 'rel'))->save();
     rdf_get_mapping('taxonomy_term', $this->vocabulary->id())->setBundleMapping(array('types' => array('skos:Concept')))->setFieldMapping('name', array('properties' => array('rdfs:label')))->save();
 }
Example #16
0
 function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->admin_user = $this->drupalCreateUser(array('administer taxonomy'));
     $this->drupalLogin($this->admin_user);
     // Create a vocabulary to which the terms will be assigned.
     $this->vocabulary = $this->createVocabulary();
     // Add some custom languages.
     foreach (array('aa', 'bb', 'cc') as $language_code) {
         $language = new Language(array('id' => $language_code, 'name' => $this->randomMachineName()));
         language_save($language);
     }
 }
Example #17
0
 protected function setUp()
 {
     parent::setUp();
     // Remove access content permission from registered users.
     user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, array('access content'));
     $this->vocabulary = $this->createVocabulary();
     // Add a field to the vocabulary.
     $entity_type = 'taxonomy_term';
     $name = 'field_test';
     entity_create('field_storage_config', array('field_name' => $name, 'entity_type' => $entity_type, 'type' => 'image', 'settings' => array('uri_scheme' => 'private')))->save();
     entity_create('field_config', array('field_name' => $name, 'entity_type' => $entity_type, 'bundle' => $this->vocabulary->id(), 'settings' => array()))->save();
     entity_get_display($entity_type, $this->vocabulary->id(), 'default')->setComponent($name, array('type' => 'image', 'settings' => array()))->save();
     entity_get_form_display($entity_type, $this->vocabulary->id(), 'default')->setComponent($name, array('type' => 'image_image', 'settings' => array()))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content', 'administer taxonomy', 'administer entity_test fields'));
     $this->drupalLogin($web_user);
     $this->vocabulary = $this->createVocabulary();
     // Setup a field.
     $this->field_name = drupal_strtolower($this->randomMachineName());
     $this->field_storage = entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => '0')))));
     $this->field_storage->save();
     entity_create('field_config', array('field_storage' => $this->field_storage, 'bundle' => 'entity_test'))->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($this->field_name, array('type' => 'options_select'))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($this->field_name, array('type' => 'taxonomy_term_reference_link'))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy'));
     $this->drupalLogin($web_user);
     $this->vocabulary = $this->createVocabulary();
     // Create the field.
     $this->fieldName = 'field_taxonomy_test';
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'full')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
     // Set the RDF mapping for the new field.
     rdf_get_mapping('node', 'article')->setFieldMapping($this->fieldName, array('properties' => array('dc:subject'), 'mapping_type' => 'rel'))->save();
     rdf_get_mapping('taxonomy_term', $this->vocabulary->id())->setBundleMapping(array('types' => array('skos:Concept')))->setFieldMapping('name', array('properties' => array('rdfs:label')))->save();
 }
Example #20
0
 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
     // Create a vocabulary and add two term reference fields to article nodes.
     $this->vocabulary = $this->createVocabulary();
     $this->fieldName1 = Unicode::strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->fieldName1, array('type' => 'entity_reference_label'))->save();
     $this->fieldName2 = Unicode::strtolower($this->randomMachineName());
     $this->createEntityReferenceField('node', 'article', $this->fieldName2, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'article', 'default')->setComponent($this->fieldName2, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->fieldName2, array('type' => 'entity_reference_label'))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access'));
     $this->drupalLogin($this->admin_user);
     // Create a vocabulary and add two term reference fields to article nodes.
     $this->vocabulary = $this->createVocabulary();
     $this->field_name_1 = drupal_strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->field_name_1, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_config', array('field_name' => $this->field_name_1, 'bundle' => 'article', 'entity_type' => 'node'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->field_name_1, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->field_name_1, array('type' => 'taxonomy_term_reference_link'))->save();
     $this->field_name_2 = drupal_strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->field_name_2, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_config', array('field_name' => $this->field_name_2, 'bundle' => 'article', 'entity_type' => 'node'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->field_name_2, array('type' => 'options_select'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->field_name_2, array('type' => 'taxonomy_term_reference_link'))->save();
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->tags = $this->getTags();
     $this->vocabulary = $this->createVocabulary();
     $this->field_tags_name = 'field_' . $this->vocabulary->id();
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     // Create the entity reference field for terms.
     $this->createEntityReferenceField('node', 'article', $this->field_tags_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     // Configure for autocomplete display.
     entity_get_form_display('node', 'article', 'default')->setComponent($this->field_tags_name, array('type' => 'entity_reference_autocomplete_tags'))->save();
     // Create user, then login.
     $this->user = $this->drupalCreateUser(array('administer site configuration', 'access sitemap', 'administer nodes', 'create article content', 'administer taxonomy'));
     $this->drupalLogin($this->user);
     // Configure the sitemap to show categories.
     $vid = $this->vocabulary->id();
     $edit = array("show_vocabularies[{$vid}]" => $vid);
     $this->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
 }
Example #23
0
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
 }
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    // Create a vocabulary.
    $this->vocabulary = $this->createVocabulary();

    // Create 11 terms, which have some sub-string in common, in a
    // non-alphabetical order, so that we will have more than 10 matches later
    // when we test the correct number of results is returned, and we can test
    // the order of the results. The location of the sub-string to match varies
    // also, since it should not be necessary to start with the sub-string to
    // match it. Save term IDs to reuse later.
    $termNames = [
      'aaa 20 bbb',
      'aaa 70 bbb',
      'aaa 10 bbb',
      'aaa 12 bbb',
      'aaa 40 bbb',
      'aaa 11 bbb',
      'aaa 30 bbb',
      'aaa 50 bbb',
      'aaa 80',
      'aaa 90',
      'bbb 60 aaa',
    ];
    foreach ($termNames as $termName) {
      $term = $this->createTerm($this->vocabulary, ['name' => $termName]);
      $this->termIds[$termName] = $term->id();
    }

    // Create a taxonomy_term_reference field on the article Content Type that
    // uses a taxonomy_autocomplete widget.
    $this->fieldName = Unicode::strtolower($this->randomMachineName());
    FieldStorageConfig::create([
      'field_name' => $this->fieldName,
      'entity_type' => 'node',
      'type' => 'entity_reference',
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
      'settings' => [
        'target_type' => 'taxonomy_term',
      ],
    ])->save();
    FieldConfig::create([
      'field_name' => $this->fieldName,
      'bundle' => 'article',
      'entity_type' => 'node',
      'settings' => [
        'handler' => 'default',
        'handler_settings' => [
          // Restrict selection of terms to a single vocabulary.
          'target_bundles' => [
            $this->vocabulary->id() => $this->vocabulary->id(),
          ],
        ],
      ],
    ])->save();
    EntityFormDisplay::load('node.article.default')
      ->setComponent($this->fieldName, [
        'type' => 'entity_reference_autocomplete',
      ])
      ->save();
    EntityViewDisplay::load('node.article.default')
      ->setComponent($this->fieldName, [
        'type' => 'entity_reference_label',
      ])
      ->save();

    // Create a user and then login.
    $this->adminUser = $this->drupalCreateUser(['create article content']);
    $this->drupalLogin($this->adminUser);

    // Retrieve the autocomplete url.
    $this->drupalGet('node/add/article');
    $result = $this->xpath('//input[@name="' . $this->fieldName . '[0][target_id]"]');
    $this->autocompleteUrl = $this->getAbsoluteUrl($result[0]['data-autocomplete-path']);
  }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer content translation']));
 }
 protected function setUp()
 {
     parent::setUp();
     $this->taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy'));
     $this->drupalLogin($this->taxonomy_admin);
 }