siteIntallD6Test.php

  1. 8.0.x tests/siteIntallD6Test.php
  2. 6.x tests/siteIntallD6Test.php
  3. 7.x tests/siteIntallD6Test.php
  4. 5.x tests/siteIntallD6Test.php

Tests for site-install on a Drupal 6 installation.

@group commands

Classes

Namesort descending Description
siteInstallD6Case

File

tests/siteIntallD6Test.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Tests for site-install on a Drupal 6 installation.
  5. *
  6. * @group commands
  7. */
  8. class siteInstallD6Case extends Drush_CommandTestCase {
  9. function setUp() {
  10. if (UNISH_DRUPAL_MAJOR_VERSION != 6) {
  11. $this->markTestSkipped('This test class is designed for Drupal 6.');
  12. return;
  13. }
  14. }
  15. /**
  16. * Test a D6 install with extra options.
  17. */
  18. public function testExtraConfigurationOptions() {
  19. // Set up codebase without installing Drupal.
  20. $sites = $this->setUpDrupal(1, FALSE, '6');
  21. $root = $this->webroot();
  22. $site = key($sites);
  23. // Copy the "example" test profile into the newly created site's profiles directory
  24. $profile_dir = "$root/profiles/example";
  25. mkdir($profile_dir);
  26. copy(dirname(__FILE__) . '/resources/example.profile', $profile_dir . '/example.profile');
  27. $test_string = $this->randomString();
  28. // example.profile Has values 0-2 defined as allowed.
  29. $test_int = rand(0, 2);
  30. $site_name = $this->randomString();
  31. $this->drush('site-install', array(
  32. // First argument is the profile name
  33. 'example',
  34. // Then the extra profile options
  35. "myopt1=$test_string",
  36. "myopt2=$test_int",
  37. ),
  38. array(
  39. 'db-url' => $this->db_url($site),
  40. 'yes' => NULL,
  41. 'sites-subdir' => $site,
  42. 'root' => $root,
  43. 'site-name' => $site_name,
  44. 'uri' => $site,
  45. ));
  46. $this->checkVariable('site_name', $site_name, $site);
  47. $this->checkVariable('myopt1', $test_string, $site);
  48. $this->checkVariable('myopt2', $test_int, $site);
  49. }
  50. /**
  51. * Check the value of a Drupal variable against an expectation using drush.
  52. *
  53. * @param $name
  54. * The variable name.
  55. * @param $value
  56. * The expected value of this variable.
  57. * @param $site
  58. * The name of an individual multisite installation site.
  59. */
  60. private function checkVariable($name, $value, $site) {
  61. $options = array(
  62. 'root' => $this->webroot(),
  63. 'uri' => $site,
  64. );
  65. $this->drush('variable-get', array($name), $options);
  66. $this->assertEquals($name . ': "' . $value . '"', $this->getOutput());
  67. }
  68. }