You are here

public function SchemaTest::tryUnsignedInsert in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::tryUnsignedInsert()

Tries to insert a negative value into columns defined as unsigned.

Parameters

string $table_name: The table to insert.

string $column_name: The column to insert.

Return value

bool TRUE if the insert succeeded, FALSE otherwise.

1 call to SchemaTest::tryUnsignedInsert()
SchemaTest::testUnsignedColumns in core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
Tests creating unsigned columns and data integrity thereof.

File

core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php, line 574

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function tryUnsignedInsert($table_name, $column_name) {
  try {
    $this->connection
      ->insert($table_name)
      ->fields([
      $column_name => -1,
    ])
      ->execute();
    return TRUE;
  } catch (\Exception $e) {
    return FALSE;
  }
}