You are here

protected function SqlServerSchemaTest::assertUnsignedField in Drupal driver for SQL Server and SQL Azure 8

1 call to SqlServerSchemaTest::assertUnsignedField()
SqlServerSchemaTest::testUnsignedField in src/Tests/SqlServerSchemaTest.php
Test adding / modifying an unsigned column.

File

src/Tests/SqlServerSchemaTest.php, line 149
Definition of Drupal\sqlsrv\Tests\SqlServerSchemaTest.

Class

SqlServerSchemaTest
Schema tests for SQL Server database driver.

Namespace

Drupal\sqlsrv\Tests

Code

protected function assertUnsignedField($table, $field_name) {
  try {
    db_insert('test_table')
      ->fields(array(
      'id' => -1,
    ))
      ->execute();
    $success = TRUE;
  } catch (DatabaseException $e) {
    $success = FALSE;
  }
  $this
    ->assertFalse($success, t('Inserting a negative value in an unsigned field failed.'));
  try {
    db_insert('test_table')
      ->fields(array(
      'id' => 1,
    ))
      ->execute();
    $success = TRUE;
  } catch (DatabaseException $e) {
    $success = FALSE;
  }
  $this
    ->assertTrue($success, t('Inserting a positive value in an unsigned field succeeded.'));
  db_delete('test_table')
    ->execute();
}