You are here

function SearchNumbersTestCase::setUp in Drupal 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

modules/search/search.test, line 1282
Tests for search.module.

Class

SearchNumbersTestCase
Tests that numbers can be searched.

Code

function setUp() {
  parent::setUp('search');
  $this->test_user = $this
    ->drupalCreateUser(array(
    'search content',
    'access content',
    'administer nodes',
    'access site reports',
  ));
  $this
    ->drupalLogin($this->test_user);

  // Create content with various numbers in it.
  // Note: 50 characters is the current limit of the search index's word
  // field.
  $this->numbers = array(
    'ISBN' => '978-0446365383',
    'UPC' => '036000 291452',
    'EAN bar code' => '5901234123457',
    'negative' => '-123456.7890',
    'quoted negative' => '"-123456.7890"',
    'leading zero' => '0777777777',
    'tiny' => '111',
    'small' => '22222222222222',
    'medium' => '333333333333333333333333333',
    'large' => '444444444444444444444444444444444444444',
    'gigantic' => '5555555555555555555555555555555555555555555555555',
    'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666',
    'date',
    '01/02/2009',
    'commas',
    '987,654,321',
  );
  foreach ($this->numbers as $doc => $num) {
    $info = array(
      'body' => array(
        LANGUAGE_NONE => array(
          array(
            'value' => $num,
          ),
        ),
      ),
      'type' => 'page',
      'language' => LANGUAGE_NONE,
      'title' => $doc . ' number',
    );
    $this->nodes[$doc] = $this
      ->drupalCreateNode($info);
  }

  // Run cron to ensure the content is indexed.
  $this
    ->cronRun();
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
}