function UpdateScriptTest::testRequirements in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Update/UpdateScriptTest.php \Drupal\system\Tests\Update\UpdateScriptTest::testRequirements()
Tests that requirements warnings and errors are correctly displayed.
File
- core/
modules/ system/ src/ Tests/ Update/ UpdateScriptTest.php, line 82 - Contains \Drupal\system\Tests\Update\UpdateScriptTest.
Class
- UpdateScriptTest
- Tests the update script access and functionality.
Namespace
Drupal\system\Tests\UpdateCode
function testRequirements() {
$update_script_test_config = $this
->config('update_script_test.settings');
$this
->drupalLogin($this->updateUser);
// If there are no requirements warnings or errors, we expect to be able to
// go through the update process uninterrupted.
$this
->drupalGet($this->updateUrl, array(
'external' => TRUE,
));
$this
->clickLink(t('Continue'));
$this
->assertText(t('No pending updates.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this
->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared when there were no requirements warnings or errors.');
// If there is a requirements warning, we expect it to be initially
// displayed, but clicking the link to proceed should allow us to go
// through the rest of the update process uninterrupted.
// First, run this test with pending updates to make sure they can be run
// successfully.
$update_script_test_config
->set('requirement_type', REQUIREMENT_WARNING)
->save();
drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1);
$this
->drupalGet($this->updateUrl, array(
'external' => TRUE,
));
$this
->assertText('This is a requirements warning provided by the update_script_test module.');
$this
->clickLink('try again');
$this
->assertNoText('This is a requirements warning provided by the update_script_test module.');
$this
->clickLink(t('Continue'));
$this
->clickLink(t('Apply pending updates'));
$this
->assertText(t('The update_script_test_update_8001() update was executed successfully.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this
->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.');
// Now try again without pending updates to make sure that works too.
$this
->drupalGet($this->updateUrl, array(
'external' => TRUE,
));
$this
->assertText('This is a requirements warning provided by the update_script_test module.');
$this
->clickLink('try again');
$this
->assertNoText('This is a requirements warning provided by the update_script_test module.');
$this
->clickLink(t('Continue'));
$this
->assertText(t('No pending updates.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this
->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after applying updates and re-running the script.');
// If there is a requirements error, it should be displayed even after
// clicking the link to proceed (since the problem that triggered the error
// has not been fixed).
$update_script_test_config
->set('requirement_type', REQUIREMENT_ERROR)
->save();
$this
->drupalGet($this->updateUrl, array(
'external' => TRUE,
));
$this
->assertText('This is a requirements error provided by the update_script_test module.');
$this
->clickLink('try again');
$this
->assertText('This is a requirements error provided by the update_script_test module.');
}