You are here

public function FeedsWebTestCase::setUp in Feeds 7.2

Same name and namespace in other branches
  1. 6 tests/feeds.test \FeedsWebTestCase::setUp()

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()

33 calls to FeedsWebTestCase::setUp()
FeedsAccountSwitcherTest::setUp in tests/FeedsAccountSwitcherTest.test
Sets up a Drupal site for running functional and integration tests.
FeedsContentTypeTest::setUp in tests/feeds_content_type.test
Sets up a Drupal site for running functional and integration tests.
FeedsCSVtoTermsTest::setUp in tests/feeds_processor_term.test
Set up test.
FeedsCSVtoUsersTest::setUp in tests/feeds_processor_user.test
Sets up a Drupal site for running functional and integration tests.
FeedsDateTimeTest::setUp in tests/feeds_date_time.test
Sets up a Drupal site for running functional and integration tests.

... See full list

33 methods override FeedsWebTestCase::setUp()
FeedsAccountSwitcherTest::setUp in tests/FeedsAccountSwitcherTest.test
Sets up a Drupal site for running functional and integration tests.
FeedsContentTypeTest::setUp in tests/feeds_content_type.test
Sets up a Drupal site for running functional and integration tests.
FeedsCSVtoTermsTest::setUp in tests/feeds_processor_term.test
Set up test.
FeedsCSVtoUsersTest::setUp in tests/feeds_processor_user.test
Sets up a Drupal site for running functional and integration tests.
FeedsDateTimeTest::setUp in tests/feeds_date_time.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

tests/feeds.test, line 17
Common functionality for all Feeds tests.

Class

FeedsWebTestCase
Test basic Data API functionality.

Code

public function setUp() {
  $args = func_get_args();

  // Build the list of required modules which can be altered by passing in an
  // array of module names to setUp().
  if (isset($args[0])) {
    if (is_array($args[0])) {
      $modules = $args[0];
    }
    else {
      $modules = $args;
    }
  }
  else {
    $modules = array();
  }
  $modules[] = 'taxonomy';
  $modules[] = 'image';
  $modules[] = 'file';
  $modules[] = 'field';
  $modules[] = 'field_ui';
  $modules[] = 'feeds';
  $modules[] = 'feeds_ui';
  $modules[] = 'feeds_tests';
  $modules[] = 'ctools';
  $modules[] = 'job_scheduler';
  $modules = array_unique($modules);
  parent::setUp($modules);

  // Add text formats Directly.
  $filtered_html_format = array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // HTML filter.
      'filter_html' => array(
        'weight' => 1,
        'status' => 1,
      ),
      // Line break filter.
      'filter_autop' => array(
        'weight' => 2,
        'status' => 1,
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  );
  $filtered_html_format = (object) $filtered_html_format;
  filter_format_save($filtered_html_format);

  // Build the list of required administration permissions. Additional
  // permissions can be passed as an array into setUp()'s second parameter.
  if (isset($args[1]) && is_array($args[1])) {
    $permissions = $args[1];
  }
  else {
    $permissions = array();
  }
  $permissions[] = 'access content';
  $permissions[] = 'administer site configuration';
  $permissions[] = 'administer content types';
  $permissions[] = 'administer nodes';
  $permissions[] = 'bypass node access';
  $permissions[] = 'administer taxonomy';
  $permissions[] = 'administer users';
  $permissions[] = 'administer feeds';
  $permissions[] = 'administer filters';
  $permissions[] = 'administer fields';

  // Create an admin user and log in.
  $this->admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->admin_user);

  // Create two content types if they don't exist yet.
  $existing_node_types = node_type_get_names();
  $types = array(
    array(
      'type' => 'page',
      'name' => 'Basic page',
      'node_options[status]' => 1,
      'node_options[promote]' => 0,
    ),
    array(
      'type' => 'article',
      'name' => 'Article',
      'node_options[status]' => 1,
      'node_options[promote]' => 1,
    ),
  );
  foreach ($types as $type) {

    // Check if the content type to add already exists. Other tests which
    // inherit from FeedsWebTestCase might already have added one of the
    // content types in one of the modules they have enabled in their startup.
    if (isset($existing_node_types[$type['type']])) {

      // Content type already exists. Continue to the next one.
      continue;
    }
    $this
      ->drupalPost('admin/structure/types/add', $type, 'Save content type');
    $this
      ->assertText("The content type " . $type['name'] . " has been added.");
  }
}