You are here

public function FractionUpdateTest::tryUnsignedInsert in Fraction 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/FractionUpdateTest.php \Drupal\Tests\fraction\Kernel\FractionUpdateTest::tryUnsignedInsert()

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

See also

\Drupal\KernelTests\Core\Database\SchemaTest::tryUnsignedInsert()

2 calls to FractionUpdateTest::tryUnsignedInsert()
FractionUpdateTest::testUpdateDenominatorSigned in tests/src/Kernel/FractionUpdateTest.php
Tests the denominator update.
FractionUpdateTest::testUpdateDenominatorSignedException in tests/src/Kernel/FractionUpdateTest.php
Tests that data over the limit triggers a message on update.

File

tests/src/Kernel/FractionUpdateTest.php, line 182

Class

FractionUpdateTest
Provides tests for updating the schema from signed to unsigned.

Namespace

Drupal\Tests\fraction\Kernel

Code

public function tryUnsignedInsert($table_name, $columns) {
  try {
    $this->container
      ->get('database')
      ->insert($table_name)
      ->fields([
      'entity_id' => 1,
      'revision_id' => 1,
      'delta' => 0,
      $columns['numerator'] => 1,
      $columns['denominator'] => -10,
    ])
      ->execute();
    return TRUE;
  } catch (\Exception $e) {
    return FALSE;
  }
}