You are here

public function SelectQueryTest::setUp in Drupal driver for SQL Server and SQL Azure 8

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

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

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.

Overrides WebTestBase::setUp

File

src/Tests/SelectQueryTest.php, line 38
Definition of Drupal\sqlsrv\Tests\SelectQueryTest.

Class

SelectQueryTest
General tests for SQL Server database driver.

Namespace

Drupal\sqlsrv\Tests

Code

public function setUp() {

  // Get a connection to use during testing.
  $connection = Database::getConnection();
  $table_spec = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'task' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
  );
  db_create_table('test_task', $table_spec);
  db_insert('test_task')
    ->fields(array(
    'task' => 'eat',
  ))
    ->execute();
  db_insert('test_task')
    ->fields(array(
    'task' => 'sleep',
  ))
    ->execute();
  db_insert('test_task')
    ->fields(array(
    'task' => 'sleep',
  ))
    ->execute();
  db_insert('test_task')
    ->fields(array(
    'task' => 'code',
  ))
    ->execute();
  db_insert('test_task')
    ->fields(array(
    'task' => 'found new band',
  ))
    ->execute();
  db_insert('test_task')
    ->fields(array(
    'task' => 'perform at superbowl',
  ))
    ->execute();
}