You are here

public function LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.4.x tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php \Drupal\Tests\lingotek\Functional\Update\LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade()
  2. 3.5.x tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php \Drupal\Tests\lingotek\Functional\Update\LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade()
  3. 3.6.x tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php \Drupal\Tests\lingotek\Functional\Update\LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade()
  4. 3.7.x tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php \Drupal\Tests\lingotek\Functional\Update\LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade()
  5. 3.8.x tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php \Drupal\Tests\lingotek\Functional\Update\LingotekUpgrade9401AddUploadedAndUpdatedFieldTest::testUpgrade()

Tests the upgrade for adding 'updated date' and 'last uploaded' fields.

File

tests/src/Functional/Update/LingotekUpgrade9401AddUploadedAndUpdatedFieldTest.php, line 28

Class

LingotekUpgrade9401AddUploadedAndUpdatedFieldTest
Tests the upgrade path for adding 'updated date' and 'last uploaded' fields.

Namespace

Drupal\Tests\lingotek\Functional\Update

Code

public function testUpgrade() {
  try {
    \Drupal::database()
      ->select('lingotek_metadata', 'lmd')
      ->fields('lmd', [
      'updated_timestamp',
      'uploaded_timestamp',
    ])
      ->execute()
      ->fetch();
    $this
      ->fail('Update 9401 seems to have run prior to updates');
  } catch (DatabaseExceptionWrapper $exception) {

    // Do nothing
  }
  $this
    ->runUpdates();
  try {
    \Drupal::database()
      ->select('lingotek_metadata', 'lmd')
      ->fields('lmd', [
      'updated_timestamp',
      'uploaded_timestamp',
    ])
      ->execute()
      ->fetch();
  } catch (DatabaseExceptionWrapper $exception) {
    $this
      ->fail('Update 9401 didn\'t add the expected fields: ' . $exception
      ->getMessage());
  }
}