You are here

public function FractionUpdateTest::testUpdateDenominatorSigned in Fraction 8

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

Tests the denominator update.

File

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

Class

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

Namespace

Drupal\Tests\fraction\Kernel

Code

public function testUpdateDenominatorSigned() {

  // Unsigned fields should reject negative values.
  foreach ($this->fieldsToUpdate as $field) {
    $this
      ->assertFalse($this
      ->tryUnsignedInsert($field['table_name'], $field['columns']), 'Column rejected a negative value.');
  }

  // Run the fraction update only.
  $post_update_registry = $this->container
    ->get('update.post_update_registry');
  foreach ($post_update_registry
    ->getModuleUpdateFunctions('fraction') as $function) {
    $function();
  }

  // Once the field is changed, negative values should be accepted. There's
  // no unintrusive way to consistently check the actual SQL schema, so
  // checking that there's a change on behaviour regarding signed/unsigned is
  // the fastest way to check.
  foreach ($this->fieldsToUpdate as $field) {
    $this
      ->assertTrue($this
      ->tryUnsignedInsert($field['table_name'], $field['columns']), 'Column accepted a negative value.');
  }
}