function UpdateContribTest::testHookUpdateStatusAlter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/update/src/Tests/UpdateContribTest.php \Drupal\update\Tests\UpdateContribTest::testHookUpdateStatusAlter()
Checks that hook_update_status_alter() works to change a status.
We provide the same external data as if aaa_update_test 8.x-1.0 were installed and that was the latest release. Then we use hook_update_status_alter() to try to mark this as missing a security update, then assert if we see the appropriate warnings on the right pages.
File
- core/
modules/ update/ src/ Tests/ UpdateContribTest.php, line 391 - Contains \Drupal\update\Tests\UpdateContribTest.
Class
- UpdateContribTest
- Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.
Namespace
Drupal\update\TestsCode
function testHookUpdateStatusAlter() {
$update_test_config = $this
->config('update_test.settings');
$update_admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'administer software updates',
));
$this
->drupalLogin($update_admin_user);
$system_info = array(
'#all' => array(
'version' => '8.0.0',
),
'aaa_update_test' => array(
'project' => 'aaa_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
),
);
$update_test_config
->set('system_info', $system_info)
->save();
$update_status = array(
'aaa_update_test' => array(
'status' => UPDATE_NOT_SECURE,
),
);
$update_test_config
->set('update_status', $update_status)
->save();
$this
->refreshUpdateStatus(array(
'drupal' => '0.0',
'aaa_update_test' => '1_0',
));
$this
->drupalGet('admin/reports/updates');
$this
->assertRaw('<h3>' . t('Modules') . '</h3>');
$this
->assertText(t('Security update required!'));
$this
->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
// Visit the reports page again without the altering and make sure the
// status is back to normal.
$update_test_config
->set('update_status', array())
->save();
$this
->drupalGet('admin/reports/updates');
$this
->assertRaw('<h3>' . t('Modules') . '</h3>');
$this
->assertNoText(t('Security update required!'));
$this
->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
// Turn the altering back on and visit the Update manager UI.
$update_test_config
->set('update_status', $update_status)
->save();
$this
->drupalGet('admin/modules/update');
$this
->assertText(t('Security update'));
// Turn the altering back off and visit the Update manager UI.
$update_test_config
->set('update_status', array())
->save();
$this
->drupalGet('admin/modules/update');
$this
->assertNoText(t('Security update'));
}