You are here

public function PatternsTestCase::setUp in Patterns 7.2

Same name and namespace in other branches
  1. 7 tests/patterns.test \PatternsTestCase::setUp()

Setups the testing environment.

Loads the patterns and libraries modules plus all those that are passed as parameters; skips the Patterns splash screen.

Parameters

array $user_modules The array of modules to enable:

bool $first (optional) If TRUE, the Patterns splash: screen is not skipped.

Overrides DrupalWebTestCase::setUp

17 calls to PatternsTestCase::setUp()
PatternsBlockTestCase::setUp in tests/block/block.test
Setups the testing environment.
PatternsColorTestCase::setUp in tests/color/color.test
Setups the testing environment.
PatternsContentTypeTestCase::setUp in tests/node/content.test
Setups the testing environment.
PatternsExportTestCase::setUp in tests/exporting/exporting.test
Setups the testing environment.
PatternsFieldTestCase::setUp in tests/field/field.test
Setups the testing environment.

... See full list

17 methods override PatternsTestCase::setUp()
PatternsBlockTestCase::setUp in tests/block/block.test
Setups the testing environment.
PatternsColorTestCase::setUp in tests/color/color.test
Setups the testing environment.
PatternsContentTypeTestCase::setUp in tests/node/content.test
Setups the testing environment.
PatternsExportTestCase::setUp in tests/exporting/exporting.test
Setups the testing environment.
PatternsFieldTestCase::setUp in tests/field/field.test
Setups the testing environment.

... See full list

File

tests/patterns.test, line 32
The base of the Patterns Component tests.

Class

PatternsTestCase
Abstract base class for testing pattern component behavior.

Code

public function setUp($user_modules = array(), $first = FALSE) {
  $modules = array(
    'patterns',
    'libraries',
  );
  if (!empty($user_modules)) {
    if (!is_array($user_modules)) {
      $user_modules = array(
        $user_modules,
      );
    }
    $modules = array_merge($modules, $user_modules);
    $modules = array_unique($modules);
  }

  // Enable any modules required for the tests.
  parent::setUp($modules);

  //fix simpletest error of importing&exporting.

  //hook_update_N() is in patterns.install, but hook_update_N can only be run by update.php. so I just put the code here.

  //by Rui.2013.1.11
  if (db_table_exists('patterns')) {
    $uuuid = array(
      'type' => 'varchar',
      'length' => 50,
      'default' => '',
      'description' => 'Identify patterns and their parent',
    );
    db_add_field('patterns', 'uuuid', $uuuid);
    $author = array(
      'type' => 'varchar',
      'length' => 30,
      'default' => '',
      'description' => 'pattern\'s author',
    );
    db_add_field('patterns', 'author', $author);
  }
  if (!$first) {

    // 'patterns_first_install' => PATTERNS_FIRST_INSTALL in
    // includes/variables.inc (may be not yet loaded)
    variable_set('patterns_first_install', FALSE);

    // TODO: Can we set the flag FIRST_INSTALL to FALSE before enabling patterns
    // so that we don't need to rebuild the menu
    menu_rebuild();
  }
  variable_set('patterns_save_file', 'public:///patterns_tests-' . rand(0, 1000000));

  // TODO: how to ensure that Spyc is installed?
  // Create users.
  $this->pat_user = $this
    ->drupalCreateUser(array(
    'administer patterns',
  ));

  // Login the patterns administrator.
  $this
    ->drupalLogin($this->pat_user);
}