123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852 |
- <?php
- class UpdateTestHelper extends DrupalWebTestCase {
-
- protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
-
-
- variable_set('update_fetch_url', url($url, array('absolute' => TRUE)));
-
- variable_set('update_test_xml_map', $xml_map);
-
- $this->drupalGet('admin/reports/updates/check');
- }
-
- protected function standardTests() {
- $this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
- $this->assertRaw(l(t('Drupal'), 'http://example.com/project/drupal'), 'Link to the Drupal project appears.');
- $this->assertNoText(t('No available releases found'));
- }
- }
- class UpdateCoreTestCase extends UpdateTestHelper {
- public static function getInfo() {
- return array(
- 'name' => 'Update core functionality',
- 'description' => 'Tests the Update Manager 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', 'administer modules'));
- $this->drupalLogin($admin_user);
- }
-
- 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!'));
- }
-
- 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.');
- }
-
- 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.');
- }
-
- function testDatestampMismatch() {
- $system_info = array(
- '#all' => array(
-
- 'version' => '7.0-dev',
- 'datestamp' => time(),
- ),
- 'block' => array(
-
- 'datestamp' => '1000000000',
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $this->refreshUpdateStatus(array('drupal' => 'dev'));
- $this->assertNoText(t('2001-Sep-'));
- $this->assertText(t('Up to date'));
- $this->assertNoText(t('Update available'));
- $this->assertNoText(t('Security update required!'));
- }
-
- function testModulePageRunCron() {
- $this->setSystemInfo7_0();
- variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
- variable_set('update_test_xml_map', array('drupal' => '0'));
- $this->cronRun();
- $this->drupalGet('admin/modules');
- $this->assertNoText(t('No update information available.'));
- }
-
- function testModulePageUpToDate() {
- $this->setSystemInfo7_0();
-
- variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
- variable_set('update_test_xml_map', array('drupal' => '0'));
- $this->drupalGet('admin/reports/updates');
- $this->clickLink(t('Check manually'));
- $this->assertText(t('Checked available update data for one project.'));
- $this->drupalGet('admin/modules');
- $this->assertNoText(t('There are updates available for your version of Drupal.'));
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- }
-
- function testModulePageRegularUpdate() {
- $this->setSystemInfo7_0();
-
- variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
- variable_set('update_test_xml_map', array('drupal' => '1'));
- $this->drupalGet('admin/reports/updates');
- $this->clickLink(t('Check manually'));
- $this->assertText(t('Checked available update data for one project.'));
- $this->drupalGet('admin/modules');
- $this->assertText(t('There are updates available for your version of Drupal.'));
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- }
-
- function testModulePageSecurityUpdate() {
- $this->setSystemInfo7_0();
-
- variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
- variable_set('update_test_xml_map', array('drupal' => '2-sec'));
- $this->drupalGet('admin/reports/updates');
- $this->clickLink(t('Check manually'));
- $this->assertText(t('Checked available update data for one project.'));
- $this->drupalGet('admin/modules');
- $this->assertNoText(t('There are updates available for your version of Drupal.'));
- $this->assertText(t('There is a security update available for your version of Drupal.'));
-
- $this->drupalGet('admin/appearance');
- $this->assertNoText(t('There are updates available for your version of Drupal.'));
- $this->assertText(t('There is a security update available for your version of Drupal.'));
-
- $this->drupalGet('admin/reports/status');
-
-
-
- $this->assertNoRaw('<li>' . t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/reports/updates');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/reports/updates/settings');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- }
-
- function testServiceUnavailable() {
- $this->refreshUpdateStatus(array(), '503-error');
-
- $this->assertNoText('SimpleXMLElement');
- $this->assertUniqueText(t('Failed to get available update data for one project.'));
- }
-
- 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');
-
- update_create_fetch_task($projecta);
- $this->assertEqual($queue->numberOfItems(), 2, 'Queue still contains two items');
-
- _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(
- 'version' => '7.0',
- ),
- );
- variable_set('update_test_system_info', $setting);
- }
- }
- class UpdateTestContribCase extends UpdateTestHelper {
- public static function getInfo() {
- return array(
- 'name' => 'Update contrib functionality',
- 'description' => 'Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.',
- 'group' => 'Update',
- );
- }
- function setUp() {
- parent::setUp('update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test');
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
- $this->drupalLogin($admin_user);
- }
-
- function testNoReleasesAvailable() {
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- 'aaa_update_test' => array(
- 'project' => 'aaa_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $this->refreshUpdateStatus(array('drupal' => '0', 'aaa_update_test' => 'no-releases'));
- $this->drupalGet('admin/reports/updates');
-
-
- $this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
- $this->assertRaw(l(t('Drupal'), 'http://example.com/project/drupal'));
- $this->assertText(t('Up to date'));
- $this->assertRaw('<h3>' . t('Modules') . '</h3>');
- $this->assertNoText(t('Update available'));
- $this->assertText(t('No available releases found'));
- $this->assertNoRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'));
- }
-
- function testUpdateContribBasic() {
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- 'aaa_update_test' => array(
- 'project' => 'aaa_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $this->refreshUpdateStatus(
- array(
- 'drupal' => '0',
- 'aaa_update_test' => '1_0',
- )
- );
- $this->standardTests();
- $this->assertText(t('Up to date'));
- $this->assertRaw('<h3>' . t('Modules') . '</h3>');
- $this->assertNoText(t('Update available'));
- $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
- }
-
- function testUpdateContribOrder() {
-
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
-
-
-
-
- 'aaa_update_test' => array(
- 'project' => 'ccc_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
-
- 'bbb_update_test' => array(
- 'project' => 'bbb_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
-
-
- 'ccc_update_test' => array(
- 'project' => 'ccc_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $this->refreshUpdateStatus(array('drupal' => '0', '#all' => '1_0'));
- $this->standardTests();
-
- $this->assertText(t('Up to date'));
- $this->assertNoText(t('Update available'));
-
-
- $this->assertText(t('AAA Update test'));
- $this->assertText(t('BBB Update test'));
- $this->assertText(t('CCC Update test'));
-
-
- $this->assertNoRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project does not appear.');
-
- $this->assertRaw(l(t('BBB Update test'), 'http://example.com/project/bbb_update_test'), 'Link to bbb_update_test project appears.');
- $this->assertRaw(l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), 'Link to bbb_update_test project appears.');
-
-
-
-
- $bbb_project_link = '<div class="project"><a href="http://example.com/project/bbb_update_test">BBB Update test</a>';
- $ccc_project_link = '<div class="project"><a href="http://example.com/project/ccc_update_test">CCC Update test</a>';
- $this->assertTrue(strpos($this->drupalGetContent(), $bbb_project_link) < strpos($this->drupalGetContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project");
- }
-
- function testUpdateBaseThemeSecurityUpdate() {
-
- db_update('system')
- ->fields(array('status' => 1))
- ->condition('type', 'theme')
- ->condition('name', 'update_test_subtheme')
- ->execute();
-
- $system_info = array(
-
- '#all' => array(
- 'version' => '7.0',
- ),
-
- 'update_test_basetheme' => array(
- 'project' => 'update_test_basetheme',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
-
- 'update_test_subtheme' => array(
- 'project' => 'update_test_subtheme',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $xml_mapping = array(
- 'drupal' => '0',
- 'update_test_subtheme' => '1_0',
- 'update_test_basetheme' => '1_1-sec',
- );
- $this->refreshUpdateStatus($xml_mapping);
- $this->assertText(t('Security update required!'));
- $this->assertRaw(l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme'), 'Link to the Update test base theme project appears.');
- }
-
- function testUpdateAdminThemeSecurityUpdate() {
-
- db_update('system')
- ->fields(array('status' => 0))
- ->condition('type', 'theme')
- ->condition('name', 'update_test_%', 'LIKE')
- ->execute();
- variable_set('admin_theme', 'update_test_admintheme');
-
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- 'update_test_admintheme' => array(
- 'project' => 'update_test_admintheme',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- 'update_test_basetheme' => array(
- 'project' => 'update_test_basetheme',
- 'version' => '7.x-1.1',
- 'hidden' => FALSE,
- ),
- 'update_test_subtheme' => array(
- 'project' => 'update_test_subtheme',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- variable_set('update_check_disabled', FALSE);
- $xml_mapping = array(
-
-
- 'drupal' => '0',
- );
- $this->refreshUpdateStatus($xml_mapping);
-
- $this->assertText('update_test_admintheme', "The admin theme is checked for update even if it's disabled");
-
- $this->assertNoText('update_test_basetheme', 'Disabled theme is not checked for update in the list.');
- $this->assertNoText('update_test_subtheme', 'Disabled theme is not checked for update in the list.');
- }
-
- function testUpdateShowDisabledThemes() {
-
- db_update('system')
- ->fields(array('status' => 0))
- ->condition('type', 'theme')
- ->condition('name', 'update_test_%', 'LIKE')
- ->execute();
-
- $system_info = array(
-
- '#all' => array(
- 'version' => '7.0',
- ),
-
- 'update_test_basetheme' => array(
- 'project' => 'update_test_basetheme',
- 'version' => '7.x-1.1',
- 'hidden' => FALSE,
- ),
-
- 'update_test_subtheme' => array(
- 'project' => 'update_test_subtheme',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
-
-
-
-
- variable_set('update_max_fetch_attempts', 99999);
- variable_set('update_test_system_info', $system_info);
- $xml_mapping = array(
- 'drupal' => '0',
- 'update_test_subtheme' => '1_0',
- 'update_test_basetheme' => '1_1-sec',
- );
- $base_theme_project_link = l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme');
- $sub_theme_project_link = l(t('Update test subtheme'), 'http://example.com/project/update_test_subtheme');
- foreach (array(TRUE, FALSE) as $check_disabled) {
- variable_set('update_check_disabled', $check_disabled);
- $this->refreshUpdateStatus($xml_mapping);
-
- $this->assertNoText(t('Themes'));
- if ($check_disabled) {
- $this->assertText(t('Disabled themes'));
- $this->assertRaw($base_theme_project_link, 'Link to the Update test base theme project appears.');
- $this->assertRaw($sub_theme_project_link, 'Link to the Update test subtheme project appears.');
- }
- else {
- $this->assertNoText(t('Disabled themes'));
- $this->assertNoRaw($base_theme_project_link, 'Link to the Update test base theme project does not appear.');
- $this->assertNoRaw($sub_theme_project_link, 'Link to the Update test subtheme project does not appear.');
- }
- }
- }
-
- function testUpdateBrokenFetchURL() {
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- 'aaa_update_test' => array(
- 'project' => 'aaa_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- 'bbb_update_test' => array(
- 'project' => 'bbb_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- 'ccc_update_test' => array(
- 'project' => 'ccc_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $xml_mapping = array(
- 'drupal' => '0',
- 'aaa_update_test' => '1_0',
- 'bbb_update_test' => 'does-not-exist',
- 'ccc_update_test' => '1_0',
- );
- $this->refreshUpdateStatus($xml_mapping);
- $this->assertText(t('Up to date'));
-
-
- $this->assertNoUniqueText(t('Up to date'));
-
- $this->assertNoText(t('Update available'));
-
-
-
- $this->assertRaw('<div class="version-status">' . t('Failed to get available update data'));
-
- $this->assertUniqueText(t('Checked available update data for 3 projects.'));
- $this->assertUniqueText(t('Failed to get available update data for one project.'));
-
- $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
- $this->assertNoRaw(l(t('BBB Update test'), 'http://example.com/project/bbb_update_test'), 'Link to bbb_update_test project does not appear.');
- $this->assertRaw(l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), 'Link to bbb_update_test project appears.');
- }
-
- function testHookUpdateStatusAlter() {
- variable_set('allow_authorize_operations', TRUE);
- $update_admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer software updates'));
- $this->drupalLogin($update_admin_user);
- $system_info = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- 'aaa_update_test' => array(
- 'project' => 'aaa_update_test',
- 'version' => '7.x-1.0',
- 'hidden' => FALSE,
- ),
- );
- variable_set('update_test_system_info', $system_info);
- $update_status = array(
- 'aaa_update_test' => array(
- 'status' => UPDATE_NOT_SECURE,
- ),
- );
- variable_set('update_test_update_status', $update_status);
- $this->refreshUpdateStatus(
- array(
- 'drupal' => '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(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
-
-
- variable_set('update_test_update_status', array());
- $this->drupalGet('admin/reports/updates');
- $this->assertRaw('<h3>' . t('Modules') . '</h3>');
- $this->assertNoText(t('Security update required!'));
- $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
-
- variable_set('update_test_update_status', $update_status);
- $this->drupalGet('admin/modules/update');
- $this->assertText(t('Security update'));
-
- variable_set('update_test_update_status', array());
- $this->drupalGet('admin/modules/update');
- $this->assertNoText(t('Security update'));
- }
- }
- class UpdateTestUploadCase extends UpdateTestHelper {
- public static function getInfo() {
- return array(
- 'name' => 'Upload and extract module functionality',
- 'description' => 'Tests the Update Manager module\'s upload and extraction functionality.',
- 'group' => 'Update',
- );
- }
- public function setUp() {
- parent::setUp('update', 'update_test');
- variable_set('allow_authorize_operations', TRUE);
- $admin_user = $this->drupalCreateUser(array('administer software updates', 'administer site configuration'));
- $this->drupalLogin($admin_user);
- }
-
- public function testUploadModule() {
-
-
-
-
- $imageTestFiles = $this->drupalGetTestFiles('image');
- $invalidArchiveFile = reset($imageTestFiles);
- $edit = array(
- 'files[project_upload]' => $invalidArchiveFile->uri,
- );
-
- $this->drupalPost('admin/modules/install', $edit, t('Install'));
- $this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())),'Only valid archives can be uploaded.');
-
-
-
- $validArchiveFile = drupal_get_path('module', 'update') . '/tests/aaa_update_test.tar.gz';
- $edit = array(
- 'files[project_upload]' => $validArchiveFile,
- );
- $this->drupalPost('admin/modules/install', $edit, t('Install'));
- $this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), 'Existing module was extracted and not reinstalled.');
- }
-
- function testFileNameExtensionMerging() {
- $this->drupalGet('admin/modules/install');
-
- $this->assertPattern('/file extensions are supported:.*update-test-extension/', "Found 'update-test-extension' extension");
-
- $this->assertPattern('/file extensions are supported:.*tar/', "Found 'tar' extension");
- }
-
- function testUpdateManagerCoreSecurityUpdateMessages() {
- $setting = array(
- '#all' => array(
- 'version' => '7.0',
- ),
- );
- variable_set('update_test_system_info', $setting);
- variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
- variable_set('update_test_xml_map', array('drupal' => '2-sec'));
-
- $this->drupalGet('admin/reports/updates');
-
-
- $this->drupalGet('admin/modules/install');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/modules/update');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/appearance/install');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/appearance/update');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/reports/updates/install');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/reports/updates/update');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- $this->drupalGet('admin/update/ready');
- $this->assertNoText(t('There is a security update available for your version of Drupal.'));
- }
- }
- 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');
- }
-
- function testUpdateBuildFetchUrl() {
-
- $project['name'] = 'update_test';
- $project['project_type'] = '';
- $project['info']['version'] = '';
- $project['info']['project status url'] = 'http://www.example.com';
- $project['includes'] = array('module1' => 'Module 1', 'module2' => 'Module 2');
- $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'.");
-
- $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.");
-
- $project['project_type'] = '';
- $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
- $expected .= '?site_key=site_key';
- $expected .= '&list=' . rawurlencode('module1,module2');
- $url = _update_build_fetch_url($project, $site_key);
- $this->assertEqual($url, $expected, "When site_key provided, '$url' should be '$expected'.");
-
-
- $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';
- $expected .= '&list=' . rawurlencode('module1,module2');
- $url = _update_build_fetch_url($project, $site_key);
- $this->assertEqual($url, $expected, "When ? is present, '$url' should be '$expected'.");
- }
- }
|