- <?php
- * Administration tests for Project Browser.
- */
- class InstallerBrowserAdministrationTestCase extends BackdropWebTestCase {
- protected $profile = 'testing';
- protected $privileged_user;
-
- public function setUp() {
-
- parent::setUp('installer', 'update', 'installer_test');
-
-
- $server_url = url('installer_test', array('absolute' => TRUE));
- config_set('installer.settings', 'installer_server', array(
- 'url' => $server_url,
- 'name' => 'Test Server',
- ));
-
-
- $this->privileged_user = $this->backdropCreateUser(array(
- 'use installer browser',
- 'administer site configuration',
- 'administer modules',
- 'administer themes',
- 'access site in maintenance mode',
- ));
- $this->backdropLogin($this->privileged_user);
- }
-
- protected function checkRequirements() {
- $errors = parent::checkRequirements();
-
- if (!extension_loaded('zip')) {
- $errors[] = 'PHP zip extension is not present.';
- }
-
- return $errors;
- }
-
- public function testProjectBrowserProjects() {
-
- $edit = array();
- $edit['search_text'] = '';
- $this->backdropPost('admin/modules/install', $edit, t('Search'));
- $this->assertText(t('Showing 1 to'), 'Module browser loaded');
-
- $edit = array();
- $edit['search_text'] = '';
- $this->backdropPost('admin/appearance/install', $edit, t('Search'));
- $this->assertText(t('Showing 1 to'), 'Theme browser loaded');
-
- $edit = array();
- $edit['search_text'] = '';
- $this->backdropPost('admin/structure/layouts/install', $edit, t('Search'));
- $this->assertText(t('Showing 1 to'), 'Layout browser loaded');
- }
-
- public function testProjectBrowserSearch() {
-
- $edit = array();
- $edit['search_text'] = 'aaa';
- $this->backdropPost('admin/modules/install', $edit, t('Search'));
- $this->assertText('Showing 1 to');
- }
-
- public function testProjectBrowserProjectEnabled() {
-
- module_load_include('inc', 'installer', 'installer.browser');
- $this->assertTrue(_installer_browser_is_project_enabled('module', 'update'), t('Make sure project enabled detection works.'));
- }
-
- public function testProjectBrowserAddRemoveQueue() {
-
- $this->backdropGet('admin/modules/install');
-
-
- $this->backdropGet('admin/installer/queue/nojs/add/ddd_installer_test', array('query' => array('destination' => 'admin/modules/install')));
- $this->assertNoText(t('Installation queue is empty.'));
- $this->assertNoText(t('Error: The project was not found.'));
-
-
- $this->backdropGet('admin/installer/queue/nojs/remove/ddd_installer_test', array('query' => array('destination' => 'admin/modules/install')));
- $this->assertText(t('Installation queue is empty.'));
- $this->assertNoText(t('Error: The project was not found.'));
- }
-
- public function testProjectBrowserInstallPage() {
-
- $this->backdropGet('admin/modules/install');
- $module_one = 'ddd_installer_test';
- $module_two = 'eee_installer_test';
-
-
- $this->backdropGet('admin/installer/queue/nojs/add/' . $module_one, array('query' => array('destination' => 'admin/modules/install')));
- $this->backdropGet('admin/installer/queue/nojs/add/' . $module_two, array('query' => array('destination' => 'admin/modules/install')));
- $this->backdropPost('admin/modules/install', array(), t('Install'));
-
-
- $this->assertText("You're about to install");
-
-
-
- $module_one_data = $this->getProjectData($module_one);
- $this->assertText($module_one_data['title'] . ' ' . $module_one_data['recommended']);
- $module_two_data = $this->getProjectData($module_two);
- $this->assertText($module_two_data['title'] . ' ' . $module_two_data['recommended']);
-
-
- $releases = $this->xpath('//div[contains(@class, "installer-browser-releases-radios")]//div[contains(@class, "form-item-releases-eee-installer-test-release-name")]');
- $this->assertEqual(count($releases), 2, 'Two releases available for EEE Installer test.');
-
-
- $this->backdropGet('admin/installer/reset/module/all');
-
-
- $this->backdropGet('admin/installer/queue/nojs/add/' . $module_one, array('query' => array('destination' => 'admin/modules/install')));
- $this->backdropPost('admin/modules/install', array(), t('Install'));
-
-
- $this->assertText("You're about to install");
-
-
- $edit = array(
-
-
-
- 'maintenance_mode' => FALSE,
- );
- $this->backdropPost(NULL, $edit, t('Install'));
-
-
-
- $dependencies_page = $this->xpath('//h1[contains(@class, "page-title") and normalize-space(text()) = "Install Dependencies"]');
- $this->assertTrue($dependencies_page, 'The Install Dependencies page was loaded');
- $this->assertText($module_two . ' ' . $module_two_data['recommended']);
-
-
- $this->assertTrue(file_exists('modules/' . $module_one), $module_one_data['title'] . ' exists in the modules directory');
-
-
- $this->backdropPost(NULL, $edit, t('Install'));
-
-
- $dependencies_page = $this->xpath('//h1[contains(@class, "page-title") and normalize-space(text()) = "Enable modules"]');
- $this->assertTrue($dependencies_page, 'The Enable modules page was loaded');
-
-
- $this->assertTrue(file_exists('modules/' . $module_two), $module_two_data['title'] . ' exists in the modules directory');
-
-
- $edit = array(
- 'modules[ddd_installer_test]' => TRUE,
- 'modules[eee_installer_test]' => TRUE,
- );
- $this->backdropPost(NULL, $edit, t('Enable modules'));
- $this->resetAll();
- $this->assertTrue(module_exists($module_one), $module_one_data['title'] . ' was enabled.');
- $this->assertTrue(module_exists($module_two), $module_two_data['title'] . ' was enabled.');
-
-
- foreach (array('ddd_installer_test', 'eee_installer_test') as $test_module) {
- $directory = backdrop_get_path('module', $test_module);
- $this->assertTrue(file_unmanaged_delete_recursive($directory), 'Deleted test module.');
- }
- }
-
-
- * Get the recommended version for a given project.
- *
- * @param $test_module
- * The test module.
- *
- * @return
- * The recommended version.
- */
- protected function getProjectData($test_module) {
- module_load_include('inc', 'installer', 'installer.browser');
- module_load_include('inc', 'update', 'update.compare');
-
- $backdrop_version = explode('.', BACKDROP_CORE_COMPATIBILITY);
- $filters = array(
- 'version' => $backdrop_version[0],
- 'type' => 'module',
- );
- $results = installer_browser_fetch_results($filters);
- $release_data = installer_browser_get_project_release_data($results['projects'][$test_module]);
- $project_data = array(
- 'existing_major' => 0,
- 'existing_version' => 0,
- 'install_type' => '',
- );
- update_calculate_project_update_status($project_data, $release_data);
- return $project_data;
- }
-
- }
-
- class InstallerTestUploadCase extends BackdropWebTestCase {
- protected $profile = 'testing';
-
- public function setUp() {
- parent::setUp(array('installer', 'update', 'installer_test'));
- $admin_user = $this->backdropCreateUser(array(
- 'administer site configuration',
- 'use installer browser',
- ));
- $this->backdropLogin($admin_user);
- }
-
-
- * Tests upload and extraction of a module.
- */
- public function testUploadModule() {
-
-
-
-
- $imageTestFiles = $this->backdropGetTestFiles('image');
- $invalidArchiveFile = reset($imageTestFiles);
- $edit = array(
- 'files[project_upload]' => $invalidArchiveFile->uri,
- );
-
- $this->backdropPost('admin/installer/manual', $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 = backdrop_get_path('module', 'update') . '/tests/aaa_update_test/aaa_update_test.tar.gz';
- $edit = array(
- 'files[project_upload]' => $validArchiveFile,
- );
- $this->backdropPost('admin/installer/manual', $edit, t('Install'));
- $this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), 'Existing module was extracted and not reinstalled.');
- }
-
-
- * Ensures that archiver extensions are properly merged in the UI.
- */
- function testFileNameExtensionMerging() {
- $this->backdropGet('admin/installer/manual');
-
- $this->assertPattern('/file extensions are supported:.*installer-test-extension/', "Found 'installer-test-extension' extension");
-
- $this->assertPattern('/file extensions are supported:.*tar/', "Found 'tar' extension");
- }
-
-
- * Checks the messages on Update Manager pages when missing a security update.
- */
- function testUpdateManagerCoreSecurityUpdateMessages() {
- $config = config('update.settings');
- $setting = array(
- '#all' => array(
- 'version' => '1.0',
- ),
- );
- $config->set('update_system_info', $setting)->save();
- $config->set('update_url', url('update-test', array('absolute' => TRUE)))->save();
- state_set('update_test_xml_map', array('backdrop' => '2-sec'));
-
- $this->backdropGet('admin/reports/updates');
-
-
-
- $update_pages = array(
- 'admin/config/system/updates',
- 'admin/installer/manual',
- 'admin/appearance/install',
- 'admin/modules/install',
- 'admin/structure/layouts/install',
- 'admin/reports/updates/install',
- 'admin/reports/updates/update',
- 'admin/update/ready',
- );
- $update_message = t('There is a security update available for your version of Backdrop.');
- foreach ($update_pages as $page) {
- $this->backdropGet($page);
- $this->assertNoText($update_message);
- }
- }
-
- }