summaryrefslogtreecommitdiff
path: root/modules/update/update.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/update/update.test')
-rw-r--r--modules/update/update.test83
1 files changed, 82 insertions, 1 deletions
diff --git a/modules/update/update.test b/modules/update/update.test
index c0f471a0a..8daa82155 100644
--- a/modules/update/update.test
+++ b/modules/update/update.test
@@ -225,6 +225,33 @@ class UpdateCoreTestCase extends UpdateTestHelper {
$this->assertUniqueText(t('Failed to get available update data for one project.'));
}
+ /**
+ * Tests that exactly one fetch task per project is created and not more.
+ */
+ function testFetchTasks() {
+ $projecta = array(
+ 'name' => 'aaa_update_test',
+ );
+ $projectb = array(
+ 'name' => 'bbb_update_test',
+ );
+ $queue = DrupalQueue::get('update_fetch_tasks');
+ $this->assertEqual($queue->numberOfItems(), 0, 'Queue is empty');
+ update_create_fetch_task($projecta);
+ $this->assertEqual($queue->numberOfItems(), 1, 'Queue contains one item');
+ update_create_fetch_task($projectb);
+ $this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
+ // Try to add project a again.
+ update_create_fetch_task($projecta);
+ $this->assertEqual($queue->numberOfItems(), 2, 'Queue still contains two items');
+
+ // Clear cache and try again.
+ _update_cache_clear();
+ drupal_static_reset('_update_create_fetch_task');
+ update_create_fetch_task($projecta);
+ $this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
+ }
+
protected function setSystemInfo7_0() {
$setting = array(
'#all' => array(
@@ -649,7 +676,7 @@ class UpdateTestUploadCase extends UpdateTestHelper {
* Ensure that archiver extensions are properly merged in the UI.
*/
function testFileNameExtensionMerging() {
- $this->drupalGet('admin/modules/install');
+ $this->drupalGet('admin/modules/install');
// Make sure the bogus extension supported by update_test.module is there.
$this->assertPattern('/file extensions are supported:.*update-test-extension/', t("Found 'update-test-extension' extension"));
// Make sure it didn't clobber the first option from core.
@@ -697,3 +724,57 @@ class UpdateTestUploadCase extends UpdateTestHelper {
}
}
+
+class UpdateCoreUnitTestCase extends DrupalUnitTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => "Unit tests",
+ 'description' => 'Test update funcionality unrelated to the database.',
+ 'group' => 'Update',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('update');
+ module_load_include('inc', 'update', 'update.fetch');
+ }
+
+ /**
+ * Tests _update_build_fetch_url according to issue 1481156
+ */
+ function testUpdateBuildFetchUrl() {
+ //first test that we didn't break the trivial case
+ $project['name'] = 'update_test';
+ $project['project_type'] = '';
+ $project['info']['version'] = '';
+ $project['info']['project status url'] = 'http://www.example.com';
+ $site_key = '';
+ $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
+ $url = _update_build_fetch_url($project, $site_key);
+ $this->assertEqual($url, $expected, "'$url' when no site_key provided should be '$expected'.");
+
+ //For disabled projects it shouldn't add the site key either.
+ $site_key = 'site_key';
+ $project['project_type'] = 'disabled';
+ $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
+ $url = _update_build_fetch_url($project, $site_key);
+ $this->assertEqual($url, $expected, "'$url' should be '$expected' for disabled projects.");
+
+ //for enabled projects, adding the site key
+ $project['project_type'] = '';
+ $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
+ $expected .= '?site_key=site_key';
+ $url = _update_build_fetch_url($project, $site_key);
+ $this->assertEqual($url, $expected, "When site_key provided, '$url' should be '$expected'.");
+
+ // http://drupal.org/node/1481156 test incorrect logic when url contains
+ // a question mark.
+ $project['info']['project status url'] = 'http://www.example.com/?project=';
+ $expected = 'http://www.example.com/?project=/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
+ $expected .= '&site_key=site_key';
+ $url = _update_build_fetch_url($project, $site_key);
+ $this->assertEqual($url, $expected, "When ? is present, '$url' should be '$expected'.");
+
+ }
+} \ No newline at end of file