You are here

function FFCTestCase::setUp in Field formatter conditions 7

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

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$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.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/ffc.test, line 23
Test file for Field formatter conditions.

Class

FFCTestCase
Group UI tests.

Code

function setUp() {
  parent::setUp('ffc', 'ffc_test');

  // Create test user.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer content types',
    'access administration pages',
    'administer nodes',
    'bypass node access',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Create tags.
  $this->terms = array(
    'Tag 1',
    'Tag 2',
    'Tag 3',
    'Tag 4',
    'Tag 5',
  );
  foreach ($this->terms as $tag) {
    $term = new stdClass();
    $term->name = $tag;
    $term->vid = 1;
    taxonomy_term_save($term);
  }

  // Create test node.
  $settings = array(
    'type' => 'article',
  );
  $tags = array(
    'value' => $this
      ->randomName(32),
    'format' => filter_default_format(),
  );
  $settings['field_tags'][LANGUAGE_NONE] = array(
    0 => array(
      'tid' => 1,
    ),
    1 => array(
      'tid' => 2,
    ),
    2 => array(
      'tid' => 3,
    ),
  );
  $this->node1 = $this
    ->drupalCreateNode($settings);
  $this->node1->name = $this->admin_user->name;

  // Verify everything is visible on node/1
  $this
    ->drupalGet('node/' . $this->node1->nid);
  $this
    ->assertText($this->node1->body[$this->node1->language][0]['value']);
  $this
    ->assertText($this->terms[0]);
  $this
    ->assertText($this->terms[1]);
  $this
    ->assertText($this->terms[2]);

  // Store the body value of node/1 for later use
  $this->nodeBodyValue = $this->node1->body[$this->node1->language][0]['value'];
}