- Patch #253501 by dww, cwgordon7 | boombatower, Dave Reid: added tests for update.module.
parent
dfa38ec66c
commit
bf7175abe5
|
@ -0,0 +1,34 @@
|
|||
<?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>7.x</api_version>
|
||||
<recommended_major>7</recommended_major>
|
||||
<supported_majors>7</supported_majors>
|
||||
<default_major>7</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 7.0</name>
|
||||
<version>7.0</version>
|
||||
<tag>DRUPAL-7-0</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>0</version_patch>
|
||||
<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>
|
||||
<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>
|
|
@ -0,0 +1,51 @@
|
|||
<?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>7.x</api_version>
|
||||
<recommended_major>7</recommended_major>
|
||||
<supported_majors>7</supported_majors>
|
||||
<default_major>7</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 7.1</name>
|
||||
<version>7.1</version>
|
||||
<tag>DRUPAL-7-1</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>1</version_patch>
|
||||
<status>published</status>
|
||||
<release_link>http://example.com/drupal-7-1-release</release_link>
|
||||
<download_link>http://example.com/drupal-7-1.tar.gz</download_link>
|
||||
<date>1250424581</date>
|
||||
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
|
||||
<filesize>2147483648</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 7.0</name>
|
||||
<version>7.0</version>
|
||||
<tag>DRUPAL-7-0</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>0</version_patch>
|
||||
<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>
|
||||
<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>
|
|
@ -0,0 +1,69 @@
|
|||
<?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>7.x</api_version>
|
||||
<recommended_major>7</recommended_major>
|
||||
<supported_majors>7</supported_majors>
|
||||
<default_major>7</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 7.2</name>
|
||||
<version>7.2</version>
|
||||
<tag>DRUPAL-7-2</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>2</version_patch>
|
||||
<status>published</status>
|
||||
<release_link>http://example.com/drupal-7-2-release</release_link>
|
||||
<download_link>http://example.com/drupal-7-2.tar.gz</download_link>
|
||||
<date>1250424641</date>
|
||||
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
|
||||
<filesize>4294967296</filesize>
|
||||
<terms>
|
||||
<term><name>Release type</name><value>New features</value></term>
|
||||
<term><name>Release type</name><value>Bug fixes</value></term>
|
||||
<term><name>Release type</name><value>Security update</value></term>
|
||||
</terms>
|
||||
</release>
|
||||
<release>
|
||||
<name>Drupal 7.1</name>
|
||||
<version>7.1</version>
|
||||
<tag>DRUPAL-7-1</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>1</version_patch>
|
||||
<status>published</status>
|
||||
<release_link>http://example.com/drupal-7-1-release</release_link>
|
||||
<download_link>http://example.com/drupal-7-1.tar.gz</download_link>
|
||||
<date>1250424581</date>
|
||||
<mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
|
||||
<filesize>2147483648</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 7.0</name>
|
||||
<version>7.0</version>
|
||||
<tag>DRUPAL-7-0</tag>
|
||||
<version_major>7</version_major>
|
||||
<version_patch>0</version_patch>
|
||||
<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>
|
||||
<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>
|
|
@ -0,0 +1,8 @@
|
|||
; $Id$
|
||||
name = Update test
|
||||
description = Support module for update module testing.
|
||||
package = Testing
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
files[] = update_test.module
|
||||
hidden = TRUE
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* Implement hook_menu().
|
||||
*/
|
||||
function update_test_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['update-test'] = array(
|
||||
'title' => t('Update test'),
|
||||
'page callback' => 'update_test_mock_page',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_system_info_alter().
|
||||
*
|
||||
* This checks the 'update_test_system_info' variable and sees if we need to
|
||||
* alter the system info for the given $file based on the setting. The setting
|
||||
* is expected to be a nested associative array. If the key '#all' is defined,
|
||||
* its subarray will include .info keys and values for all modules and themes
|
||||
* on the system. Otherwise, the settings array is keyed by the module or
|
||||
* theme short name ($file->name) and the subarrays contain settings just for
|
||||
* that module or theme.
|
||||
*/
|
||||
function update_test_system_info_alter(&$info, $file) {
|
||||
$setting = variable_get('update_test_system_info', array());
|
||||
foreach (array('#all', $file->name) as $id) {
|
||||
if (!empty($setting[$id])) {
|
||||
foreach ($setting[$id] as $key => $value) {
|
||||
$info[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback, prints mock XML for the update module.
|
||||
*/
|
||||
function update_test_mock_page() {
|
||||
$xml = variable_get('update_test_xml', FALSE);
|
||||
// Note: this will cause an exception to occur if no variable was set and
|
||||
// $file is FALSE.
|
||||
readfile(drupal_get_path('module', 'update_test') . "/$xml");
|
||||
}
|
|
@ -4,9 +4,10 @@ description = Checks the status of available updates for Drupal and your install
|
|||
version = VERSION
|
||||
package = Core
|
||||
core = 7.x
|
||||
files[] = update.module
|
||||
files[] = update.compare.inc
|
||||
files[] = update.fetch.inc
|
||||
files[] = update.install
|
||||
files[] = update.module
|
||||
files[] = update.report.inc
|
||||
files[] = update.settings.inc
|
||||
files[] = update.install
|
||||
files[] = update.test
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file contains tests for the update module.
|
||||
*/
|
||||
|
||||
class UpdateTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Update functionality',
|
||||
'description' => 'Tests the update module through a series of functional tests using mock XML data.',
|
||||
'group' => 'Update',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('update_test', 'update');
|
||||
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the update module when no updates are available.
|
||||
*/
|
||||
function testNoUpdatesAvailable() {
|
||||
$this->setSystemInfo7_0();
|
||||
$this->refreshUpdateData('no-updates.xml');
|
||||
$this->drupalGet('admin/reports/updates');
|
||||
$this->standardTests();
|
||||
$this->assertText(t('Up to date'));
|
||||
$this->assertNoText(t('Update available'));
|
||||
$this->assertNoText(t('Security update required!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the update module when one normal update ("7.1") is available.
|
||||
*/
|
||||
function testNormalUpdateAvailable() {
|
||||
$this->setSystemInfo7_0();
|
||||
$this->refreshUpdateData('normal-update.xml');
|
||||
$this->drupalGet('admin/reports/updates');
|
||||
$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'), t('Link to release appears.'));
|
||||
$this->assertRaw(l(t('Download'), 'http://example.com/drupal-7-1.tar.gz'), t('Link to download appears.'));
|
||||
$this->assertRaw(l(t('Release notes'), 'http://example.com/drupal-7-1-release'), t('Link to release notes appears.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the update module when a security update ("7.2") is available.
|
||||
*/
|
||||
function testSecurityUpdateAvailable() {
|
||||
$this->setSystemInfo7_0();
|
||||
$this->refreshUpdateData('security-update.xml');
|
||||
$this->drupalGet('admin/reports/updates');
|
||||
$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'), t('Link to release appears.'));
|
||||
$this->assertRaw(l(t('Download'), 'http://example.com/drupal-7-2.tar.gz'), t('Link to download appears.'));
|
||||
$this->assertRaw(l(t('Release notes'), 'http://example.com/drupal-7-2-release'), t('Link to release notes appears.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: force te update cache to refresh based on the contents of
|
||||
* the specified XML file.
|
||||
*
|
||||
* @param $xml
|
||||
* The file name of the XML file to use for mock update data.
|
||||
*/
|
||||
protected function refreshUpdateData($xml) {
|
||||
variable_set('update_test_xml', $xml);
|
||||
$this->drupalGet('admin/reports/updates/check');
|
||||
}
|
||||
|
||||
protected function setSystemInfo7_0() {
|
||||
$setting = array(
|
||||
'#all' => array(
|
||||
'version' => '7.0',
|
||||
),
|
||||
);
|
||||
variable_set('update_test_system_info', $setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: run a series of assertions that are applicable for all
|
||||
* update statuses.
|
||||
*/
|
||||
protected function standardTests() {
|
||||
$this->assertRaw(l(t('Check manually'), 'admin/reports/updates/check'), t('Link to check available updates manually appears.'));
|
||||
$this->assertRaw(l(t('Drupal'), 'http://example.com/project/drupal'), t('Link to the Drupal project appears.'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue