You are here

protected function SchemaTestExtended::assertSignedField in Drupal driver for SQL Server and SQL Azure 8.2

Summary of assertSignedField

Parameters

string $table:

string $field_name:

1 call to SchemaTestExtended::assertSignedField()
SchemaTestExtended::testUnsignedField in tests/src/Kernel/SchemaTestExtended.php
Test adding / modifying an unsigned column.

File

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

Class

SchemaTestExtended
Tests table creation and modification via the schema API.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

protected function assertSignedField($table, $field_name) {
  try {
    $this->connection
      ->insert($table)
      ->fields(array(
      $field_name => -1,
    ))
      ->execute();
    $success = TRUE;
  } catch (DatabaseException $e) {
    $success = FALSE;
  }
  $this
    ->assertTrue($success, t('Inserting a negative value in a signed field succeeded.'));
  try {
    $this->connection
      ->insert($table)
      ->fields(array(
      $field_name => 1,
    ))
      ->execute();
    $success = TRUE;
  } catch (DatabaseException $e) {
    $success = FALSE;
  }
  $this
    ->assertTrue($success, t('Inserting a positive value in a signed field succeeded.'));
  $this->connection
    ->delete($table)
    ->execute();
}