1 views_ui.test ViewsUIWizardTaggedWithTestCase::setUp()

Sets up a Backdrop site for running functional and integration tests.

Generates a random database prefix and installs Backdrop with the specified installation profile in BackdropWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Return value

bool: TRUE if set up completes, FALSE if an error occurred.

Overrides ViewsUIWizardHelper::setUp

See also

BackdropWebTestCase::prepareDatabasePrefix()

BackdropWebTestCase::changeDatabasePrefix()

BackdropWebTestCase::prepareEnvironment()

File

core/modules/views/tests/views_ui.test, line 245
Tests Views UI Wizard.

Class

ViewsUIWizardTaggedWithTestCase
Tests the ability of the views wizard to create views filtered by taxonomy.

Code

function setUp() {
  parent::setUp();

  // Create two content types. One will have an autocomplete tagging field,
  // and one won't.
  $this->node_type_with_tags = $this->backdropCreateContentType();
  $this->node_type_without_tags = $this->backdropCreateContentType();

  // Create the vocabulary for the tag field.
  $this->tag_vocabulary = new TaxonomyVocabulary(array(
    'name' => 'Views testing tags',
    'machine_name' => 'views_testing_tags',
  ));
  $this->tag_vocabulary->save();

  // Create the tag field itself.
  $this->tag_field = array(
    'field_name' => 'field_views_testing_tags',
    'type' => 'taxonomy_term_reference',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        array(
          'vocabulary' => $this->tag_vocabulary->machine_name,
          'parent' => 0,
        ),
      ),
    ),
  );
  field_create_field($this->tag_field);

  // Create an instance of the tag field on one of the content types, and
  // configure it to display an autocomplete widget.
  $this->tag_instance = array(
    'field_name' => 'field_views_testing_tags',
    'entity_type' => 'node',
    'bundle' => $this->node_type_with_tags->type,
    'widget' => array(
      'type' => 'taxonomy_autocomplete',
    ),
    'display' => array(
      'default' => array(
        'type' => 'taxonomy_term_reference_link',
        'weight' => 10,
      ),
      'teaser' => array(
        'type' => 'taxonomy_term_reference_link',
        'weight' => 10,
      ),
    ),
  );
  field_create_instance($this->tag_instance);
}