You are here

public function SchemaTestExtended::testNumericFieldPrecision in Drupal driver for SQL Server and SQL Azure 8.2

Test numeric field precision.

File

tests/src/Kernel/SchemaTestExtended.php, line 418

Class

SchemaTestExtended
Tests table creation and modification via the schema API.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testNumericFieldPrecision() {
  $table_spec = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'numeric',
        'precision' => 400,
        'scale' => 2,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema = $this->connection
    ->schema();
  $success = FALSE;
  try {
    $schema
      ->createTable('test_table_binary', $table_spec);
    $success = TRUE;
  } catch (Exception $error) {
    $success = FALSE;
  }
  $this
    ->assertTrue($success, t('Able to create a numeric field with an out of bounds precision.'));
}