You are here

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

Same name and namespace in other branches
  1. 7.3 tests/sqlsrv.schema.test \SqlServerSchemaTest::assertUnsignedField()
  2. 7.2 tests/sqlsrv.schema.test \SqlServerSchemaTest::assertUnsignedField()

Test insert data in unsigned field.

1 call to SqlServerSchemaTest::assertUnsignedField()
SqlServerSchemaTest::testUnsignedField in tests/sqlsrv.schema.test
Test adding / modifying an unsigned column.

File

tests/sqlsrv.schema.test, line 142
Support tests for SQL Server.

Class

SqlServerSchemaTest
@file Support tests for SQL Server.

Code

protected function assertUnsignedField($table, $field_name) {
  try {
    db_insert('test_table')
      ->fields(array(
      'id' => -1,
    ))
      ->execute();
    $success = TRUE;
  } catch (Exception $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 (Exception $e) {
    $success = FALSE;
  }
  $this
    ->assertTrue($success, t('Inserting a positive value in an unsigned field succeeded.'));
  db_delete('test_table')
    ->execute();
}