Commit cac5f7aa authored by alexpott's avatar alexpott
Browse files

Issue #2315849 by Devin Carlson | Gábor Hojtsy: Update status does not have...

Issue #2315849 by Devin Carlson | Gábor Hojtsy: Update status does not have tests with (semantic) Drupal 8 versions.
parent 40db9b98
......@@ -36,7 +36,7 @@ protected function setUp() {
function testNoReleasesAvailable() {
$system_info = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
'aaa_update_test' => array(
'project' => 'aaa_update_test',
......@@ -45,7 +45,7 @@ function testNoReleasesAvailable() {
),
);
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(array('drupal' => '0', 'aaa_update_test' => 'no-releases'));
$this->refreshUpdateStatus(array('drupal' => '0.0', 'aaa_update_test' => 'no-releases'));
$this->drupalGet('admin/reports/updates');
// Cannot use $this->standardTests() because we need to check for the
// 'No available releases found' string.
......@@ -67,7 +67,7 @@ function testNoReleasesAvailable() {
function testUpdateContribBasic() {
$system_info = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
'aaa_update_test' => array(
'project' => 'aaa_update_test',
......@@ -78,7 +78,7 @@ function testUpdateContribBasic() {
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
array(
'drupal' => '0',
'drupal' => '0.0',
'aaa_update_test' => '1_0',
)
);
......@@ -103,10 +103,10 @@ function testUpdateContribBasic() {
* inside system_rebuild_module_data() for example).
*/
function testUpdateContribOrder() {
// We want core to be version 7.0.
// We want core to be version 8.0.0.
$system_info = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
// All the rest should be visible as contrib modules at version 8.x-1.0.
......@@ -135,7 +135,7 @@ function testUpdateContribOrder() {
),
);
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(array('drupal' => '0', '#all' => '1_0'));
$this->refreshUpdateStatus(array('drupal' => '0.0', '#all' => '1_0'));
$this->standardTests();
// We're expecting the report to say all projects are up to date.
$this->assertText(t('Up to date'));
......@@ -172,9 +172,9 @@ function testUpdateBaseThemeSecurityUpdate() {
// Define the initial state for core and the subtheme.
$system_info = array(
// We want core to be version 7.0.
// We want core to be version 8.0.0.
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
// Show the update_test_basetheme
'update_test_basetheme' => array(
......@@ -191,7 +191,7 @@ function testUpdateBaseThemeSecurityUpdate() {
);
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$xml_mapping = array(
'drupal' => '0',
'drupal' => '0.0',
'update_test_subtheme' => '1_0',
'update_test_basetheme' => '1_1-sec',
);
......@@ -219,9 +219,9 @@ function testUpdateShowDisabledThemes() {
// Define the initial state for core and the test contrib themes.
$system_info = array(
// We want core to be version 7.0.
// We want core to be version 8.0.0.
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
// The update_test_basetheme should be visible and up to date.
'update_test_basetheme' => array(
......@@ -243,7 +243,7 @@ function testUpdateShowDisabledThemes() {
$update_settings->set('fetch.max_attempts', 99999)->save();
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$xml_mapping = array(
'drupal' => '0',
'drupal' => '0.0',
'update_test_subtheme' => '1_0',
'update_test_basetheme' => '1_1-sec',
);
......@@ -305,7 +305,7 @@ function testUpdateHiddenBaseTheme() {
function testUpdateBrokenFetchURL() {
$system_info = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
'aaa_update_test' => array(
'project' => 'aaa_update_test',
......@@ -326,7 +326,7 @@ function testUpdateBrokenFetchURL() {
\Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
$xml_mapping = array(
'drupal' => '0',
'drupal' => '0.0',
'aaa_update_test' => '1_0',
'bbb_update_test' => 'does-not-exist',
'ccc_update_test' => '1_0',
......@@ -370,7 +370,7 @@ function testHookUpdateStatusAlter() {
$system_info = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
'aaa_update_test' => array(
'project' => 'aaa_update_test',
......@@ -387,7 +387,7 @@ function testHookUpdateStatusAlter() {
$update_test_config->set('update_status', $update_status)->save();
$this->refreshUpdateStatus(
array(
'drupal' => '0',
'drupal' => '0.0',
'aaa_update_test' => '1_0',
)
);
......
......@@ -28,47 +28,135 @@ protected function setUp() {
$this->drupalLogin($admin_user);
}
/**
* Sets the version to x.x.x when no project-specific mapping is defined.
*
* @param string $version
* The version.
*/
protected function setSystemInfo($version) {
$setting = array(
'#all' => array(
'version' => $version,
),
);
\Drupal::config('update_test.settings')->set('system_info', $setting)->save();
}
/**
* Tests the Update Manager module when no updates are available.
*/
function testNoUpdatesAvailable() {
$this->setSystemInfo7_0();
$this->refreshUpdateStatus(array('drupal' => '0'));
$this->standardTests();
$this->assertText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertNoText(t('Security update required!'));
foreach (array(0, 1) as $minor_version) {
foreach (array(0, 1) as $patch_version) {
foreach (array('-alpha1', '-beta1', '') as $extra_version) {
$this->setSystemInfo("8.$minor_version.$patch_version" . $extra_version);
$this->refreshUpdateStatus(array('drupal' => "$minor_version.$patch_version" . $extra_version));
$this->standardTests();
$this->assertText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertNoText(t('Security update required!'));
}
}
}
}
/**
* Tests the Update Manager module when one normal update is available.
*/
function testNormalUpdateAvailable() {
$this->setSystemInfo7_0();
$this->refreshUpdateStatus(array('drupal' => '1'));
$this->standardTests();
$this->assertNoText(t('Up to date'));
$this->assertText(t('Update available'));
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l('7.1', 'http://example.com/drupal-7-1-release'), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), 'http://example.com/drupal-7-1.tar.gz'), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), 'http://example.com/drupal-7-1-release'), 'Link to release notes appears.');
$this->setSystemInfo('8.0.0');
foreach (array(0, 1) as $minor_version) {
foreach (array('-alpha1', '-beta1', '') as $extra_version) {
$this->refreshUpdateStatus(array('drupal' => "$minor_version.1" . $extra_version));
$this->standardTests();
$this->drupalGet('admin/reports/updates/check');
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l("8.$minor_version.1" . $extra_version, "http://example.com/drupal-8-$minor_version-1$extra_version-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-8-$minor_version-1$extra_version.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-8-$minor_version-1$extra_version-release"), 'Link to release notes appears.');
switch ($minor_version) {
case 0:
// Both stable and unstable releases are available.
// A stable release is the latest.
if ($extra_version == '') {
$this->assertNoText(t('Up to date'));
$this->assertText(t('Update available'));
$this->assertText(t('Recommended version:'));
$this->assertNoText(t('Latest version:'));
}
// Only unstable releases are available.
// An unstable release is the latest.
else {
$this->assertText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertNoText(t('Recommended version:'));
$this->assertText(t('Latest version:'));
}
break;
case 1:
// Both stable and unstable releases are available.
// A stable release is the latest.
if ($extra_version == '') {
$this->assertNoText(t('Up to date'));
$this->assertText(t('Update available'));
$this->assertText(t('Recommended version:'));
$this->assertNoText(t('Latest version:'));
}
// Both stable and unstable releases are available.
// An unstable release is the latest.
else {
$this->assertNoText(t('Up to date'));
$this->assertText(t('Update available'));
$this->assertText(t('Recommended version:'));
$this->assertText(t('Latest version:'));
}
break;
}
}
}
}
/**
* Tests the Update Manager module when a major update is available.
*/
function testMajorUpdateAvailable() {
foreach (array(0, 1) as $minor_version) {
foreach (array(0, 1) as $patch_version) {
foreach (array('-alpha1', '-beta1', '') as $extra_version) {
$this->setSystemInfo("8.$minor_version.$patch_version" . $extra_version);
$this->refreshUpdateStatus(array('drupal' => '9'));
$this->standardTests();
$this->drupalGet('admin/reports/updates/check');
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l('9.0.0', "http://example.com/drupal-9-0-0-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-9-0-0.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-9-0-0-release"), 'Link to release notes appears.');
$this->assertNoText(t('Up to date'));
$this->assertText(t('Not supported!'));
$this->assertText(t('Recommended version:'));
$this->assertNoText(t('Latest version:'));
}
}
}
}
/**
* Tests the Update Manager module when a security update is available.
*/
function testSecurityUpdateAvailable() {
$this->setSystemInfo7_0();
$this->refreshUpdateStatus(array('drupal' => '2-sec'));
$this->standardTests();
$this->assertNoText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertText(t('Security update required!'));
$this->assertRaw(_l('7.2', 'http://example.com/drupal-7-2-release'), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), 'http://example.com/drupal-7-2.tar.gz'), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), 'http://example.com/drupal-7-2-release'), 'Link to release notes appears.');
foreach (array(0, 1) as $minor_version) {
$this->setSystemInfo("8.$minor_version.0");
$this->refreshUpdateStatus(array('drupal' => "$minor_version.2-sec"));
$this->standardTests();
$this->assertNoText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertText(t('Security update required!'));
$this->assertRaw(_l("8.$minor_version.2", "http://example.com/drupal-8-$minor_version-2-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-8-$minor_version-2.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-8-$minor_version-2-release"), 'Link to release notes appears.');
}
}
/**
......@@ -78,7 +166,7 @@ function testDatestampMismatch() {
$system_info = array(
'#all' => array(
// We need to think we're running a -dev snapshot to see dates.
'version' => '7.0-dev',
'version' => '8.0.0-dev',
'datestamp' => time(),
),
'block' => array(
......@@ -98,9 +186,13 @@ function testDatestampMismatch() {
* Checks that running cron updates the list of available updates.
*/
function testModulePageRunCron() {
$this->setSystemInfo7_0();
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
\Drupal::config('update_test.settings')->set('xml_map', array('drupal' => '0'))->save();
$this->setSystemInfo('8.0.0');
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update_test.settings')
->set('xml_map', array('drupal' => '0.0'))
->save();
$this->cronRun();
$this->drupalGet('admin/modules');
......@@ -111,10 +203,14 @@ function testModulePageRunCron() {
* Checks the messages at admin/modules when the site is up to date.
*/
function testModulePageUpToDate() {
$this->setSystemInfo7_0();
$this->setSystemInfo('8.0.0');
// Instead of using refreshUpdateStatus(), set these manually.
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
\Drupal::config('update_test.settings')->set('xml_map', array('drupal' => '0'))->save();
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update_test.settings')
->set('xml_map', array('drupal' => '0.0'))
->save();
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
......@@ -128,10 +224,14 @@ function testModulePageUpToDate() {
* Checks the messages at admin/modules when an update is missing.
*/
function testModulePageRegularUpdate() {
$this->setSystemInfo7_0();
$this->setSystemInfo('8.0.0');
// Instead of using refreshUpdateStatus(), set these manually.
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
\Drupal::config('update_test.settings')->set('xml_map', array('drupal' => '1'))->save();
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update_test.settings')
->set('xml_map', array('drupal' => '0.1'))
->save();
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
......@@ -145,10 +245,14 @@ function testModulePageRegularUpdate() {
* Checks the messages at admin/modules when a security update is missing.
*/
function testModulePageSecurityUpdate() {
$this->setSystemInfo7_0();
$this->setSystemInfo('8.0.0');
// Instead of using refreshUpdateStatus(), set these manually.
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
\Drupal::config('update_test.settings')->set('xml_map', array('drupal' => '2-sec'))->save();
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update_test.settings')
->set('xml_map', array('drupal' => '0.2-sec'))
->save();
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
......@@ -217,27 +321,19 @@ function testFetchTasks() {
* Checks language module in core package at admin/reports/updates.
*/
function testLanguageModuleUpdate() {
$this->setSystemInfo7_0();
$this->setSystemInfo('8.0.0');
// Instead of using refreshUpdateStatus(), set these manually.
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
\Drupal::config('update_test.settings')->set('xml_map', array('drupal' => '1'))->save();
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update_test.settings')
->set('xml_map', array('drupal' => '0.1'))
->save();
$this->drupalGet('admin/reports/updates');
$this->assertText(t('Language'));
}
/**
* Sets the version to 7.0 when no project-specific mapping is defined.
*/
protected function setSystemInfo7_0() {
$setting = array(
'#all' => array(
'version' => '7.0',
),
);
\Drupal::config('update_test.settings')->set('system_info', $setting)->save();
}
/**
* Ensures that the local actions appear.
*/
......
......@@ -72,14 +72,16 @@ function testFileNameExtensionMerging() {
function testUpdateManagerCoreSecurityUpdateMessages() {
$setting = array(
'#all' => array(
'version' => '7.0',
'version' => '8.0.0',
),
);
\Drupal::config('update_test.settings')
->set('system_info', $setting)
->set('xml_map', array('drupal' => '2-sec'))
->set('xml_map', array('drupal' => '0.2-sec'))
->save();
\Drupal::config('update.settings')
->set('fetch.url', _url('update-test', array('absolute' => TRUE)))
->save();
\Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save();
// Initialize the update status.
$this->drupalGet('admin/reports/updates');
......
......@@ -16,11 +16,11 @@
<release>
<name>aaa_update_test 8.x-1.0</name>
<version>8.x-1.0</version>
<tag>DRUPAL-7--1-0</tag>
<tag>DRUPAL-8--1-0</tag>
<version_major>1</version_major>
<version_patch>0</version_patch>
<status>published</status>
<release_link>http://example.com/aaa_update_test-7-x-1-0-release</release_link>
<release_link>http://example.com/aaa_update_test-8-x-1-0-release</release_link>
<download_link>http://example.com/aaa_update_test-8.x-1.0.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
......
<?xml version="1.0" encoding="utf-8"?>
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Drupal</title>
<short_name>drupal</short_name>
<dc:creator>Drupal</dc:creator>
<api_version>8.x</api_version>
<recommended_major>8</recommended_major>
<supported_majors>8</supported_majors>
<default_major>8</default_major>
<project_status>published</project_status>
<link>http://example.com/project/drupal</link>
<terms>
<term><name>Projects</name><value>Drupal project</value></term>
</terms>
<releases>
<release>
<name>Drupal 8.0.0-alpha1</name>
<version>8.0.0-alpha1</version>
<tag>DRUPAL-8-0-0-alpha1</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>
<version_patch>0</version_patch>
<version_extra>alpha1</version_extra>
<status>published</status>
<release_link>http://example.com/drupal-8-0-0-alpha1-release</release_link>
<download_link>http://example.com/drupal-8-0-0-alpha1.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
<filesize>1073741824</filesize>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
</releases>
</project>
......@@ -4,9 +4,9 @@
<short_name>drupal</short_name>
<dc:creator>Drupal</dc:creator>
<api_version>8.x</api_version>
<recommended_major>7</recommended_major>
<supported_majors>7</supported_majors>
<default_major>7</default_major>
<recommended_major>8</recommended_major>
<supported_majors>8</supported_majors>
<default_major>8</default_major>
<project_status>published</project_status>
<link>http://example.com/project/drupal</link>
<terms>
......@@ -14,14 +14,35 @@
</terms>
<releases>
<release>
<name>Drupal 7.0</name>
<version>7.0</version>
<tag>DRUPAL-7-0</tag>
<version_major>7</version_major>
<name>Drupal 8.0.0-beta1</name>
<version>8.0.0-beta1</version>
<tag>DRUPAL-8-0-0-beta1</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>
<version_patch>0</version_patch>
<version_extra>beta1</version_extra>
<status>published</status>
<release_link>http://example.com/drupal-8-0-0-beta1-release</release_link>
<download_link>http://example.com/drupal-8-0-0-beta1.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
<filesize>1073741824</filesize>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
<release>
<name>Drupal 8.0.0-alpha1</name>
<version>8.0.0-alpha1</version>
<tag>DRUPAL-8-0-0-alpha1</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>
<version_patch>0</version_patch>
<version_extra>alpha1</version_extra>
<status>published</status>
<release_link>http://example.com/drupal-7-0-release</release_link>
<download_link>http://example.com/drupal-7-0.tar.gz</download_link>
<release_link>http://example.com/drupal-8-0-0-alpha1-release</release_link>
<download_link>http://example.com/drupal-8-0-0-alpha1.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
<filesize>1073741824</filesize>
......
<?xml version="1.0" encoding="utf-8"?>
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Drupal</title>
<short_name>drupal</short_name>
<dc:creator>Drupal</dc:creator>
<api_version>8.x</api_version>
<recommended_major>8</recommended_major>
<supported_majors>8</supported_majors>
<default_major>8</default_major>
<project_status>published</project_status>
<link>http://example.com/project/drupal</link>
<terms>
<term><name>Projects</name><value>Drupal project</value></term>
</terms>
<releases>
<release>
<name>Drupal 8.0.0</name>
<version>8.0.0</version>
<tag>DRUPAL-8-0-0</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>
<version_patch>0</version_patch>
<status>published</status>
<release_link>http://example.com/drupal-8-0-0-release</release_link>
<download_link>http://example.com/drupal-8-0-0.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
<filesize>1073741824</filesize>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
<release>
<name>Drupal 8.0.0-beta1</name>
<version>8.0.0-beta1</version>
<tag>DRUPAL-8-0-0-beta1</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>
<version_patch>0</version_patch>
<version_extra>beta1</version_extra>
<status>published</status>
<release_link>http://example.com/drupal-8-0-0-beta1-release</release_link>
<download_link>http://example.com/drupal-8-0-0-beta1.tar.gz</download_link>
<date>1250424521</date>
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
<filesize>1073741824</filesize>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
<release>
<name>Drupal 8.0.0-alpha1</name>
<version>8.0.0-alpha1</version>
<tag>DRUPAL-8-0-0-alpha1</tag>
<version_major>8</version_major>
<version_minor>0</version_minor>