You are here

protected function SchemaTest::setUp in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 4.2.x tests/src/Kernel/SchemaTest.php \Drupal\Tests\sqlsrv\Kernel\SchemaTest::setUp()
  2. 3.0.x tests/src/Kernel/SchemaTest.php \Drupal\Tests\sqlsrv\Kernel\SchemaTest::setUp()
  3. 3.1.x tests/src/Kernel/SchemaTest.php \Drupal\Tests\sqlsrv\Kernel\SchemaTest::setUp()
  4. 4.0.x tests/src/Kernel/SchemaTest.php \Drupal\Tests\sqlsrv\Kernel\SchemaTest::setUp()
  5. 4.1.x tests/src/Kernel/SchemaTest.php \Drupal\Tests\sqlsrv\Kernel\SchemaTest::setUp()

Overrides DatabaseTestBase::setUp

File

tests/src/Kernel/SchemaTest.php, line 34

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

protected function setUp() {
  parent::setUp();

  /** @var \Drupal\Driver\Database\sqlsrv\Schema $schema */
  $schema = $this->connection
    ->schema();
  $this->schema = $schema;
  $this->table = [
    'description' => 'New Comment',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'name' => [
        'description' => "A person's name",
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'binary' => TRUE,
      ],
      'age' => [
        'description' => "The person's age",
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'job' => [
        'description' => "The person's job",
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'Undefined',
      ],
    ],
    'primary key' => [
      'id',
    ],
    'unique keys' => [
      'name' => [
        'name',
      ],
    ],
    'indexes' => [
      'ages' => [
        'age',
      ],
    ],
  ];
}