function UpdatePathTestBaseTest::testUpdateHookN

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testUpdateHookN()
  2. 10 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testUpdateHookN()
  3. 11.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testUpdateHookN()

Test that updates are properly run.

File

core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php, line 83

Class

UpdatePathTestBaseTest
Tests the update path base class.

Namespace

Drupal\FunctionalTests\Update

Code

public function testUpdateHookN() {
    $connection = Database::getConnection();
    // Increment the schema version.
    \Drupal::state()->set('update_test_schema_version', 8001);
    $this->runUpdates();
    $select = $connection->select('watchdog');
    $select->orderBy('wid', 'DESC');
    $select->range(0, 5);
    $select->fields('watchdog', [
        'message',
    ]);
    $container_cannot_be_saved_messages = array_filter(iterator_to_array($select->execute()), function ($row) {
        return strpos($row->message, 'Container cannot be saved to cache.') !== FALSE;
    });
    $this->assertEqual([], $container_cannot_be_saved_messages);
    // Ensure schema has changed.
    $this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001);
    $this->assertEqual(drupal_get_installed_schema_version('update_test_semver_update_n', TRUE), 8001);
    // Ensure the index was added for column a.
    $this->assertTrue($connection->schema()
        ->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.');
    // Ensure update_test_semver_update_n_update_8001 was run.
    $this->assertEquals(\Drupal::state()->get('update_test_semver_update_n_update_8001'), 'Yes, I was run. Thanks for testing!');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.