You are here

public function SchemaTest::tryUnsignedInsert in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::tryUnsignedInsert()
  2. 9 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.

File

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

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;
  }
}