1 installer.test public InstallerBrowserAdministrationTestCase::testProjectBrowserInstallPage()

File

core/modules/installer/tests/installer.test, line 88

Class

InstallerBrowserAdministrationTestCase
Administration tests for Project Browser.

Code

public function testProjectBrowserInstallPage() {
  // Refresh the page.
  $this->backdropGet('admin/modules/install');
  $module_one = 'ddd_installer_test';
  $module_two = 'eee_installer_test';

  // Attempt to install a project.
  $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'));

  // Check that this is the install page.
  $this->assertText("You're about to install");

  // Check that two projects are listed for install and the recommended
  // version is shown.
  $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']);

  // Check that two versions of EEE Installer test are listed.
  $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.');

  // Cancel and go back to project list.
  $this->backdropGet('admin/installer/reset/module/all');

  // Check project installs.
  $this->backdropGet('admin/installer/queue/nojs/add/' . $module_one, array('query' => array('destination' => 'admin/modules/install')));
  $this->backdropPost('admin/modules/install', array(), t('Install'));

  // Check that this is the install page.
  $this->assertText("You're about to install");

  // Set maintenance mode off.
  $edit = array(
    // Cannot test in maintenance mode, as the HTTP request to fetch projects
    // always will fail since we are fetching from the (now offline) site
    // itself.
    'maintenance_mode' => FALSE,
  );
  $this->backdropPost(NULL, $edit, t('Install'));

  // Check that dependencies install page loaded with the recommended
  // dependency selected.
  $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']);

  // Test that the test module was really downloaded.
  $this->assertTrue(file_exists('modules/' . $module_one), $module_one_data['title'] . ' exists in the modules directory');

  // Test that project two installs.
  $this->backdropPost(NULL, $edit, t('Install'));

  // Check that enable page loaded.
  $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');

  // Test that the test module was really downloaded.
  $this->assertTrue(file_exists('modules/' . $module_two), $module_two_data['title'] . ' exists in the modules directory');

  // Enable both modules.
  $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.');

  // Delete the test module files.
  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.');
  }
}