protected function SchemaTestExtended::assertUnsignedField in Drupal driver for SQL Server and SQL Azure 8.2
Summary of assertUnsignedField
Parameters
string $table:
string $field_name:
1 call to SchemaTestExtended::assertUnsignedField()
- SchemaTestExtended::testUnsignedField in tests/
src/ Kernel/ SchemaTestExtended.php - Test adding / modifying an unsigned column.
File
- tests/
src/ Kernel/ SchemaTestExtended.php, line 215
Class
- SchemaTestExtended
- Tests table creation and modification via the schema API.
Namespace
Drupal\Tests\sqlsrv\KernelCode
protected function assertUnsignedField($table, $field_name) {
try {
$this->connection
->insert($table)
->fields(array(
$field_name => -1,
))
->execute();
$success = TRUE;
} catch (DatabaseException $e) {
$success = FALSE;
}
$this
->assertFalse($success, t('Inserting a negative value in an unsigned field failed.'));
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 an unsigned field succeeded.'));
$this->connection
->delete($table)
->execute();
}