first import
This commit is contained in:
73
sites/all/modules/drush/tests/COVERAGE.txt
Normal file
73
sites/all/modules/drush/tests/COVERAGE.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
COMMANDS (perhaps keep these notes in $command definition?)
|
||||
------------
|
||||
pm-download: GOOD.
|
||||
pm-updatecode: GOOD.
|
||||
pm-update
|
||||
pm-releasenotes
|
||||
pm-releases
|
||||
pm-enable: GOOD. testEnDisUnList().
|
||||
pm-disable: GOOD. testEnDisUnList().
|
||||
pm-uninstall: GOOD. testEnDisUnList().
|
||||
pm-list: GOOD. testEnDisUnList().
|
||||
pm-info:
|
||||
pm-refresh
|
||||
version-control: FAIR. See updatecode. To be deprecated all git workflow after git.drupal.org?
|
||||
package-hander:
|
||||
|
||||
sql-cli:
|
||||
sql-connect:
|
||||
sql-query:
|
||||
sql-dump: FAIR. Implicitly tested by siteUpgradeTest.
|
||||
sql-sync: FAIR. Implicitly tested by siteUpgradeTest.
|
||||
sql-drop:
|
||||
|
||||
|
||||
updatedb: GOOD. Implicitly tested siteUpgradeTest.
|
||||
archive-dump: GOOD
|
||||
archive-restore:
|
||||
help
|
||||
version: Good. Implicit by testStandaloneScript()
|
||||
self-update
|
||||
php-eval: GOOD. Implicitly tested by many tests (e.g. siteUpgradeTest).
|
||||
php-script: GOOD.
|
||||
drupal-directory: GOOD
|
||||
core-cli: FAIR
|
||||
cache-clear
|
||||
core-cron
|
||||
core-status: FAIR: Implicit test by contextTest.
|
||||
docs
|
||||
image
|
||||
core-rsync
|
||||
search-*
|
||||
site-install: FAIR. Implicit test by setUpDrupal().
|
||||
site-upgrade: GOOD.
|
||||
test-*
|
||||
topic
|
||||
variable-*: GOOD.
|
||||
watchdog-*
|
||||
|
||||
user-*: GOOD.
|
||||
|
||||
field-*: GOOD.
|
||||
|
||||
INCLUDES
|
||||
------------
|
||||
backend: GOOD
|
||||
batch: FAIR. Implicit by siteUpgradeTest.
|
||||
command: FAIR
|
||||
context: FAIR
|
||||
drush: NONE.
|
||||
environment
|
||||
sitealias. FAIR. Explicit test for alias lists. Single aliases implicitly tested by contextTest.
|
||||
dbtng: Good. Implicit by variable-*.
|
||||
drupal
|
||||
exec: GOOD: Implicitly tested all over.
|
||||
filesystem
|
||||
output
|
||||
|
||||
|
||||
ROOT
|
||||
-------------
|
||||
drush
|
||||
drush.php
|
||||
drush.bat
|
||||
44
sites/all/modules/drush/tests/README.txt
Normal file
44
sites/all/modules/drush/tests/README.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
Drush's test suite based on phpunit (http://www.phpunit.de/).
|
||||
|
||||
Usage
|
||||
--------
|
||||
- Install PHPUnit [*]
|
||||
- Optional. Copy phpunit.xml.dist to phpunit.xml and customize if needed.
|
||||
- From the /tests subdirectory, run `phpunit .` or `runner.php .`
|
||||
|
||||
Advanced usage
|
||||
---------
|
||||
- Run only tests matching a regex: phpunit --filter=testVersionString .
|
||||
- XML results: phpunit --filter=testVersionString --log-junit results.xml .
|
||||
|
||||
Notes
|
||||
----------
|
||||
- I have run tests within Netbeans and it works.
|
||||
- Speedup downloads with Squid as forward proxy - http://reluctanthacker.rollett.org/node/114.
|
||||
|
||||
|
||||
|
||||
[*] Install PHPUnit:
|
||||
|
||||
Drush requires PHPUnit 3.5 or later; installing with PEAR is easiest.
|
||||
|
||||
On Linux:
|
||||
---------
|
||||
|
||||
sudo apt-get install php5-curl php-pear
|
||||
sudo pear upgrade --force PEAR
|
||||
sudo pear channel-discover pear.phpunit.de
|
||||
sudo pear channel-discover components.ez.no
|
||||
sudo pear channel-discover pear.symfony-project.com
|
||||
sudo pear install --alldeps phpunit/PHPUnit
|
||||
|
||||
On Windows:
|
||||
-----------
|
||||
|
||||
Download and save from go-pear.phar http://pear.php.net/go-pear.phar
|
||||
|
||||
php -q go-pear.phar
|
||||
pear channel-discover pear.phpunit.de
|
||||
pear channel-discover components.ez.no
|
||||
pear channel-discover pear.symfony-project.com
|
||||
pear install --alldeps phpunit/PHPUnit
|
||||
51
sites/all/modules/drush/tests/archiveDumpTest.php
Normal file
51
sites/all/modules/drush/tests/archiveDumpTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for archive.drush.inc
|
||||
*/
|
||||
class archiveDumpCase extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Test dump and extraction.
|
||||
*/
|
||||
public function testArchiveDump() {
|
||||
$env = 'testarchivedump';
|
||||
$this->setUpDrupal($env, TRUE, '6');
|
||||
$root = $this->sites[$env]['root'];
|
||||
$docroot = 'web';
|
||||
|
||||
// Create the alias for D7 site.
|
||||
$aliases['archivedump'] = array(
|
||||
'root' => UNISH_SANDBOX . '/' . $docroot,
|
||||
'uri' => $env,
|
||||
);
|
||||
$contents = $this->file_aliases($aliases);
|
||||
$alias_path = "$root/aliases.drushrc.php";
|
||||
file_put_contents($alias_path, $contents);
|
||||
|
||||
$name = "example";
|
||||
$dump_dest = "dump.tar.gz";
|
||||
$options = array(
|
||||
'root' => $root,
|
||||
'uri' => $env,
|
||||
'yes' => NULL,
|
||||
'destination' => 'dump.tar.gz',
|
||||
);
|
||||
$this->drush('archive-dump', array('@archivedump'), $options);
|
||||
$exec = sprintf('file %s/%s', UNISH_SANDBOX, $dump_dest);
|
||||
$this->execute($exec);
|
||||
$output = $this->getOutput();
|
||||
$expected = UNISH_SANDBOX . "/dump.tar.gz: gzip compressed data, from Unix";
|
||||
$this->assertEquals($expected, $output);
|
||||
|
||||
// Untar it, make sure it looks right.
|
||||
$exec = sprintf('tar -xzf %s/%s', UNISH_SANDBOX, $dump_dest);
|
||||
$untar_dest = UNISH_SANDBOX . '/untar';
|
||||
$exec = sprintf('mkdir %s && cd %s && tar xzf %s/%s', $untar_dest, $untar_dest, UNISH_SANDBOX, $dump_dest);
|
||||
$this->execute($exec);
|
||||
$this->execute(sprintf('head %s/unish_%s.sql | grep "MySQL dump"', $untar_dest, $env));
|
||||
$this->execute('test -f ' . $untar_dest . '/MANIFEST.ini');
|
||||
$this->execute('test -d ' . $untar_dest . '/' . $docroot);
|
||||
}
|
||||
}
|
||||
85
sites/all/modules/drush/tests/backendTest.php
Normal file
85
sites/all/modules/drush/tests/backendTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* We choose to test the backend system in two parts.
|
||||
* - Origin. These tests assure that we are generate a proper ssh command
|
||||
* when a backend invoke is needed.
|
||||
* - Target. These tests assure that drush generates a delimited JSON array
|
||||
* when called with --backend option.
|
||||
*
|
||||
* Advantages of this approach:
|
||||
* - No network calls and thus more robust.
|
||||
* - No network calls and thus faster.
|
||||
*/
|
||||
|
||||
class backendCase extends Drush_TestCase {
|
||||
const DRUSH_BACKEND_OUTPUT_DELIMITER = 'DRUSH_BACKEND_OUTPUT_START>>>%s<<<DRUSH_BACKEND_OUTPUT_END';
|
||||
|
||||
/*
|
||||
* Covers the following origin responsibilities.
|
||||
* - A remote host is recognized in site specification.
|
||||
* - Generates expected ssh command.
|
||||
*
|
||||
* General handling of site aliases will be in sitealiasTest.php.
|
||||
*/
|
||||
function testOrigin() {
|
||||
$exec = sprintf('%s %s version --simulate --ssh-options=%s | grep ssh', self::escapeshellarg(UNISH_DRUSH), self::escapeshellarg('user@server/path/to/drupal#sitename'), self::escapeshellarg('-i mysite_dsa'));
|
||||
$this->execute($exec);
|
||||
// $expected might be different on non unix platforms. We shall see.
|
||||
$expected = "proc_open: ssh -i mysite_dsa 'user'@'server' 'drush --uri='\''sitename'\'' --root='\''/path/to/drupal'\'' --simulate version --backend 2>&1' 2>&1";
|
||||
$output = $this->getOutput();
|
||||
$this->assertEquals($expected, $output, 'Expected ssh command was built');
|
||||
}
|
||||
|
||||
/*
|
||||
* Covers the following target responsibilities.
|
||||
* - Interpret stdin as options as per REST API.
|
||||
* - Successfully execute specified command.
|
||||
* - JSON object has expected contents (including errors).
|
||||
* - JSON object is wrapped in expected delimiters.
|
||||
*/
|
||||
function testTarget() {
|
||||
$stdin = json_encode(array('filter'=>'sql'));
|
||||
$exec = sprintf('echo %s | %s help --backend', self::escapeshellarg($stdin), self::escapeshellarg(UNISH_DRUSH));
|
||||
$this->execute($exec);
|
||||
$parsed = $this->parse($this->getOutput());
|
||||
$this->assertTrue((bool) $parsed, 'Successfully parsed backend output');
|
||||
$this->assertArrayHasKey('log', $parsed);
|
||||
$this->assertArrayHasKey('output', $parsed);
|
||||
$this->assertArrayHasKey('object', $parsed);
|
||||
$this->assertEquals(self::EXIT_SUCCESS, $parsed['error_status']);
|
||||
// This assertion shows that `help` was called and that stdin options were respected.
|
||||
$this->assertStringStartsWith('SQL commands', $parsed['output']);
|
||||
$this->assertEquals('Bootstrap to phase 0.', $parsed['log'][0]['message']);
|
||||
|
||||
// Check error propogation by requesting an invalid command (missing Drupal site).
|
||||
$exec = sprintf('%s core-cron --backend 2>/dev/null', self::escapeshellarg(UNISH_DRUSH));
|
||||
$this->execute($exec, self::EXIT_ERROR);
|
||||
$parsed = $this->parse($this->getOutput());
|
||||
$this->assertEquals(1, $parsed['error_status']);
|
||||
$this->assertArrayHasKey('DRUSH_NO_DRUPAL_ROOT', $parsed['error_log']);
|
||||
}
|
||||
|
||||
/*
|
||||
* A slightly less functional copy of drush_backend_parse_output().
|
||||
*/
|
||||
function parse($string) {
|
||||
$regex = sprintf(self::DRUSH_BACKEND_OUTPUT_DELIMITER, '(.*)');
|
||||
preg_match("/$regex/s", $string, $match);
|
||||
if ($match[1]) {
|
||||
// we have our JSON encoded string
|
||||
$output = $match[1];
|
||||
// remove the match we just made and any non printing characters
|
||||
$string = trim(str_replace(sprintf(self::DRUSH_BACKEND_OUTPUT_DELIMITER, $match[1]), '', $string));
|
||||
}
|
||||
|
||||
if ($output) {
|
||||
$data = json_decode($output, TRUE);
|
||||
if (is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
56
sites/all/modules/drush/tests/commandTest.php
Normal file
56
sites/all/modules/drush/tests/commandTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class commandCase extends Drush_TestCase {
|
||||
public function testInvoke() {
|
||||
$expected = array(
|
||||
'unit_drush_init',
|
||||
'drush_unit_invoke_init',
|
||||
'drush_unit_invoke_validate',
|
||||
'drush_unit_pre_unit_invoke',
|
||||
'drush_unit_invoke',
|
||||
'drush_unit_post_unit_invoke',
|
||||
'drush_unit_post_unit_invoke_rollback',
|
||||
'drush_unit_pre_unit_invoke_rollback',
|
||||
'drush_unit_invoke_validate_rollback',
|
||||
);
|
||||
|
||||
// We expect a return code of 1 so just call execute() directly.
|
||||
$exec = sprintf('%s unit-invoke --include=%s', UNISH_DRUSH, self::escapeshellarg(dirname(__FILE__)));
|
||||
$this->execute($exec, self::EXIT_ERROR);
|
||||
$called = json_decode($this->getOutput());
|
||||
$this->assertSame($expected, $called);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Assert that $command has interesting properties. Reference command by
|
||||
* it's alias (dl) to assure that those aliases are built as expected.
|
||||
*/
|
||||
public function testGetCommands() {
|
||||
$eval = '$commands = drush_get_commands();';
|
||||
$eval .= 'print json_encode($commands[\'dl\'])';
|
||||
$this->drush('php-eval', array($eval));
|
||||
$command = json_decode($this->getOutput());
|
||||
|
||||
$this->assertEquals('dl', current($command->aliases));
|
||||
$this->assertEquals('download', current($command->{'deprecated-aliases'}));
|
||||
$this->assertObjectHasAttribute('version_control', $command->engines);
|
||||
$this->assertObjectHasAttribute('package_handler', $command->engines);
|
||||
$this->assertEquals('pm-download', $command->command);
|
||||
$this->assertEquals('pm', $command->commandfile);
|
||||
$this->assertEquals('drush_command', $command->callback);
|
||||
$this->assertObjectHasAttribute('examples', $command->sections);
|
||||
$this->assertTrue($command->is_alias);
|
||||
}
|
||||
|
||||
/*
|
||||
* Assert that minimum bootstrap phase is honored.
|
||||
*
|
||||
* Not testing dependency on a module since that requires an installed Drupal.
|
||||
* Too slow for little benefit.
|
||||
*/
|
||||
public function testRequirementBootstrapPhase() {
|
||||
// Assure that core-cron fails when run outside of a Drupal site.
|
||||
$return = $this->execute(UNISH_DRUSH . ' core-cron --quiet', self::EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
150
sites/all/modules/drush/tests/contextTest.php
Normal file
150
sites/all/modules/drush/tests/contextTest.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Assure that context API behaves as designed. Mostly implicitly tested, but we
|
||||
* do have some edges that need explicit testing.
|
||||
*
|
||||
* @see drush/includes/context.inc.
|
||||
*/
|
||||
|
||||
class contextCase extends Drush_TestCase {
|
||||
|
||||
function setUpPaths() {
|
||||
$this->root = $this->sites[$this->env]['root'];
|
||||
$this->site = $this->root . '/sites/' . $this->env;
|
||||
$this->home = UNISH_SANDBOX . '/home';
|
||||
$this->paths = array(
|
||||
'custom' => UNISH_SANDBOX,
|
||||
'site' => $this->site,
|
||||
'drupal' => $this->root,
|
||||
'user' => $this->home,
|
||||
'home.drush' => $this->home . '/.drush',
|
||||
'system' => UNISH_SANDBOX . '/etc/drush',
|
||||
// We don't want to write a file into drush dir since it is not in the sandbox.
|
||||
// 'drush' => dirname(realpath(UNISH_DRUSH)),
|
||||
);
|
||||
// Run each path through realpath() since the paths we'll compare against
|
||||
// will have already run through drush_load_config_file().
|
||||
foreach ($this->paths as $key => $path) $this->paths[$key] = realpath($path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to write a tiny drushrc.php to each place that drush checks. Also
|
||||
* write a sites/dev/aliases.drushrc.php file to the sandbox.
|
||||
*/
|
||||
function setup() {
|
||||
parent::setUp();
|
||||
|
||||
$this->env = 'dev';
|
||||
$this->setUpDrupal($this->env, FALSE);
|
||||
$this->setUpPaths();
|
||||
|
||||
// These files are only written to sandbox so get automatically cleaned up.
|
||||
foreach ($this->paths as $key => $path) {
|
||||
$contents = <<<EOD
|
||||
<?php
|
||||
// Written by Drush's contextCase::setup(). This file is safe to delete.
|
||||
|
||||
\$options['contextConfig'] = '$key';
|
||||
\$command_specific['unit-eval']['contextConfig'] = '$key-specific';
|
||||
|
||||
EOD;
|
||||
$path .= $key == 'user' ? '/.drushrc.php' : '/drushrc.php';
|
||||
if (file_put_contents($path, $contents)) {
|
||||
$this->written[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
// Also write a site alias so we can test its supremacy in context hierarchy.
|
||||
$path = $this->site . '/aliases.drushrc.php';
|
||||
$aliases['contextAlias'] = array(
|
||||
'contextConfig' => 'alias1',
|
||||
'command-specific' => array (
|
||||
'unit-eval' => array (
|
||||
'contextConfig' => 'alias-specific',
|
||||
),
|
||||
),
|
||||
);
|
||||
$contents = $this->file_aliases($aliases);
|
||||
$return = file_put_contents($path, $contents);
|
||||
}
|
||||
|
||||
/*
|
||||
* These should be two different tests but I could not work out how to do that
|
||||
* without calling setup() twice. setupBeforeClass() did not work out (for MW).
|
||||
*/
|
||||
function testContext() {
|
||||
$this->ConfigFile();
|
||||
$this->ContextHierarchy();
|
||||
}
|
||||
|
||||
/*
|
||||
* Assure that all possible config files get loaded.
|
||||
*/
|
||||
function ConfigFile() {
|
||||
$options = array(
|
||||
'pipe' => NULL,
|
||||
'config' => UNISH_SANDBOX,
|
||||
'root' => $this->root,
|
||||
'uri' => $this->env,
|
||||
);
|
||||
$this->drush('core-status', array('Drush configuration'), $options);
|
||||
$output = trim($this->getOutput());
|
||||
$loaded = explode(' ', $output);
|
||||
$this->assertSame($this->written, $loaded);
|
||||
}
|
||||
|
||||
/*
|
||||
* Assure that options are loaded into right context and hierarchy is
|
||||
* respected by drush_get_option().
|
||||
*
|
||||
* Stdin context not exercised here. See backendCase::testTarget().
|
||||
*/
|
||||
function ContextHierarchy() {
|
||||
// The 'custom' config file has higher priority than cli and regular config files.
|
||||
$eval = '$contextConfig = drush_get_option("contextConfig", "n/a");';
|
||||
$eval .= '$cli1 = drush_get_option("cli1");';
|
||||
$eval .= 'print json_encode(get_defined_vars());';
|
||||
$config = UNISH_SANDBOX . '/drushrc.php';
|
||||
$options = array(
|
||||
'cli1' => NULL,
|
||||
'config' => $config,
|
||||
'root' => $this->root,
|
||||
'uri' => $this->env,
|
||||
);
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$actuals = json_decode(trim($output));
|
||||
$this->assertEquals('custom', $actuals->contextConfig);
|
||||
$this->assertTrue($actuals->cli1);
|
||||
|
||||
// Site alias trumps 'custom'.
|
||||
$eval = '$contextConfig = drush_get_option("contextConfig", "n/a");';
|
||||
$eval .= 'print json_encode(get_defined_vars());';
|
||||
$options = array(
|
||||
'config' => $config,
|
||||
'root' => $this->root,
|
||||
'uri' => $this->env,
|
||||
);
|
||||
$this->drush('php-eval', array($eval), $options, '@contextAlias');
|
||||
$output = $this->getOutput();
|
||||
$actuals = json_decode(trim($output));
|
||||
$this->assertEquals('alias1', $actuals->contextConfig);
|
||||
|
||||
// Command specific wins over non-specific. If it did not, $expected would
|
||||
// be 'site'. Note we call unit-eval command in order not to purturb
|
||||
// php-eval with options in config file.
|
||||
$eval = '$contextConfig = drush_get_option("contextConfig", "n/a");';
|
||||
$eval .= 'print json_encode(get_defined_vars());';
|
||||
$options = array(
|
||||
'root' => $this->root,
|
||||
'uri' => $this->env,
|
||||
'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
|
||||
);
|
||||
$this->drush('unit-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$actuals = json_decode(trim($output));
|
||||
$this->assertEquals('site-specific', $actuals->contextConfig);
|
||||
}
|
||||
}
|
||||
115
sites/all/modules/drush/tests/coreTest.php
Normal file
115
sites/all/modules/drush/tests/coreTest.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for core commands.
|
||||
*/
|
||||
class coreCase extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Test standalone php-script scripts. Assure that script args and options work.
|
||||
*/
|
||||
public function testStandaloneScript() {
|
||||
$this->drush('version', array('drush_version'), array('pipe' => NULL));
|
||||
$standard = $this->getOutput();
|
||||
|
||||
// Write out a hellounish.script into the sandbox. The correct /path/to/drush
|
||||
// is in the shebang line.
|
||||
$filename = 'hellounish.script';
|
||||
$data = '#!/usr/bin/env [PATH-TO-DRUSH]
|
||||
|
||||
$arg = drush_shift();
|
||||
drush_invoke("version", $arg);
|
||||
';
|
||||
$data = str_replace('[PATH-TO-DRUSH]', UNISH_DRUSH, $data);
|
||||
$script = UNISH_SANDBOX . '/' . $filename;
|
||||
file_put_contents($script, $data);
|
||||
chmod($script, 0755);
|
||||
$this->execute("$script drush_version --pipe");
|
||||
$standalone = $this->getOutput();
|
||||
$this->assertEquals($standard, $standalone);
|
||||
}
|
||||
|
||||
function testDrupalDirectory() {
|
||||
$this->setUpDrupal('dev', TRUE);
|
||||
$root = $this->sites['dev']['root'];
|
||||
$options = array(
|
||||
'root' => $root,
|
||||
'uri' => 'dev',
|
||||
'verbose' => NULL,
|
||||
'yes' => NULL,
|
||||
);
|
||||
$this->drush('pm-download', array('devel-7.x-1.0'), $options);
|
||||
$this->drush('pm-enable', array('menu', 'devel'), $options);
|
||||
|
||||
$this->drush('drupal-directory', array('devel'), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEquals($root . '/sites/all/modules/devel', $output);
|
||||
|
||||
$this->drush('drupal-directory', array('%files'), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEquals($root . '/sites/dev/files', $output);
|
||||
|
||||
$this->drush('drupal-directory', array('%modules'), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEquals($root . '/sites/all/modules', $output);
|
||||
}
|
||||
|
||||
function testCoreCLI() {
|
||||
/*
|
||||
* @todo
|
||||
* - BASHRC_PATH. Same file cleanup woes as contextTest.
|
||||
* - DRUSH_CLI
|
||||
* - INITIAL_SITE
|
||||
* - PS1. Hard to test in non interactive session?
|
||||
* - on
|
||||
* - use
|
||||
* - cd, cdd, lsd
|
||||
* - override, contextual
|
||||
*/
|
||||
|
||||
// Exercise core-cli's interactive mode.
|
||||
// Include unit.drush.inc commandfile.
|
||||
$options = array(
|
||||
'include' => dirname(__FILE__),
|
||||
);
|
||||
// These commands will throw a failure if they return non-zero exit code.
|
||||
// Assure that we create a bash function for command names.
|
||||
$options['unit-extra'] = 'core-status;exit';
|
||||
$this->drush('core-cli', array(), $options);
|
||||
// Assure that we create a bash function for command aliases.
|
||||
$options['unit-extra'] = 'st;exit';
|
||||
$this->drush('core-cli', array(), $options);
|
||||
|
||||
// Assure that we create a bash alias for site aliases.
|
||||
// First, write an alias file to the sandbox.
|
||||
$path = UNISH_SANDBOX . '/aliases.drushrc.php';
|
||||
$aliases['cliAlias'] = array(
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
);
|
||||
$contents = $this->file_aliases($aliases);
|
||||
$return = file_put_contents($path, $contents);
|
||||
// Append a bash command which starts with alias name (i.e. @cliAlias).
|
||||
$options['unit-extra'] = sprintf('@cliAlias core-status --alias-path=%s;exit', UNISH_SANDBOX);
|
||||
$options['alias-path'] = UNISH_SANDBOX;
|
||||
$this->drush('core-cli', array(), $options);
|
||||
|
||||
// $this->markTestIncomplete('In progress below.');
|
||||
// Exercise core-cli's non-interactive mode.
|
||||
// We spawn our own bash session using the --pipe feature of core-cli.
|
||||
//$options = array(
|
||||
// 'pipe' => NULL,
|
||||
// 'alias-path' => UNISH_SANDBOX,
|
||||
//);
|
||||
//$this->drush('core-cli', array(), $options);
|
||||
//$bashrc_data = $this->getOutput();
|
||||
//$bashrc_file = UNISH_SANDBOX . '/.bashrc';
|
||||
//$extra = 'cd @cliAlias;exit;';
|
||||
//$return = file_put_contents($bashrc_file, $bashrc_data . $extra);
|
||||
//$this->setUpDrupal('dev', FALSE);
|
||||
//$this->execute('bash --rcfile ' . $bashrc_file);
|
||||
//$output = $this->getOutput();
|
||||
//$this->assertContains('????', $output);
|
||||
}
|
||||
}
|
||||
1101
sites/all/modules/drush/tests/devel.xml
Normal file
1101
sites/all/modules/drush/tests/devel.xml
Normal file
File diff suppressed because it is too large
Load Diff
340
sites/all/modules/drush/tests/drush_testcase.inc
Normal file
340
sites/all/modules/drush/tests/drush_testcase.inc
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Initialize a sandboxed environment. Starts with call unish_init() at bottom.
|
||||
*/
|
||||
|
||||
abstract class Drush_TestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
// Unix exit codes.
|
||||
const EXIT_SUCCESS = 0;
|
||||
const EXIT_ERROR = 1;
|
||||
|
||||
/*
|
||||
* An array of Drupal sites that are setup in the drush-sandbox.
|
||||
*/
|
||||
var $sites;
|
||||
|
||||
function __construct() {
|
||||
$this->_output = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that each class starts with an empty sandbox directory and
|
||||
* a clean environment - http://drupal.org/node/1103568.
|
||||
*/
|
||||
public static function setUpBeforeClass() {
|
||||
$sandbox = UNISH_SANDBOX;
|
||||
if (file_exists($sandbox)) {
|
||||
unish_file_delete_recursive($sandbox);
|
||||
}
|
||||
$ret = mkdir($sandbox, 0777, TRUE);
|
||||
chdir(UNISH_SANDBOX);
|
||||
|
||||
mkdir(getenv('HOME') . '/.drush', 0777, TRUE);
|
||||
mkdir($sandbox . '/etc/drush', 0777, TRUE);
|
||||
mkdir($sandbox . '/share/drush/commands', 0777, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs after each test case. Remove sandbox directory.
|
||||
*/
|
||||
public static function tearDownAfterClass() {
|
||||
if (file_exists(UNISH_SANDBOX)) {
|
||||
unish_file_delete_recursive(UNISH_SANDBOX);
|
||||
}
|
||||
}
|
||||
|
||||
public static function is_windows() {
|
||||
return (strtoupper(substr(PHP_OS, 0, 3)) == "WIN");
|
||||
}
|
||||
|
||||
public static function escapeshellarg($arg) {
|
||||
// Short-circuit escaping for simple params (keep stuff readable)
|
||||
if (preg_match('|^[a-zA-Z0-9.:/_-]*$|', $arg)) {
|
||||
return $arg;
|
||||
}
|
||||
elseif (self::is_windows()) {
|
||||
return self::_escapeshellarg_windows($arg);
|
||||
}
|
||||
else {
|
||||
return escapeshellarg($arg);
|
||||
}
|
||||
}
|
||||
|
||||
public static function _escapeshellarg_windows($arg) {
|
||||
// Double up existing backslashes
|
||||
$arg = preg_replace('/\\\/', '\\\\\\\\', $arg);
|
||||
|
||||
// Escape double quotes.
|
||||
$arg = preg_replace('/"/', '\\"', $arg);
|
||||
|
||||
// Escape single quotes.
|
||||
$arg = preg_replace('/\'/', '\\\'', $arg);
|
||||
|
||||
// Add surrounding quotes.
|
||||
$arg = '"' . $arg . '"';
|
||||
|
||||
return $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually runs the command. Does not trap the error stream output as this
|
||||
* need PHP 4.3+.
|
||||
*
|
||||
* @param string $command
|
||||
* The actual command line to run.
|
||||
* @return integer
|
||||
* Exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS.
|
||||
*/
|
||||
function execute($command, $expected_return = self::EXIT_SUCCESS) {
|
||||
$this->_output = FALSE;
|
||||
// todo check verbose level from phpunit.
|
||||
if (TRUE) {
|
||||
print "\nExecuting: $command \n";
|
||||
}
|
||||
exec($command, $this->_output, $return);
|
||||
$this->assertEquals($expected_return, $return, 'Unexpected exit code: ' . $command);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke drush in via execute().
|
||||
*
|
||||
* @param command
|
||||
* A defined drush command such as 'cron', 'status' or any of the available ones such as 'drush pm'.
|
||||
* @param args
|
||||
* Command arguments.
|
||||
* @param $options
|
||||
* An associative array containing options.
|
||||
* @param $site_specification
|
||||
* A site alias or site specification. Include the '@' at start of a site alias.
|
||||
* @param $cd
|
||||
* A directory to change into before executing.
|
||||
* @return integer
|
||||
* An exit code.
|
||||
*/
|
||||
function drush($command, array $args = array(), array $options = array(), $site_specification = NULL, $cd = NULL) {
|
||||
$cmd[] = $cd ? sprintf('cd %s;', self::escapeshellarg($cd)) : NULL;
|
||||
$cmd[] = UNISH_DRUSH;
|
||||
$cmd[] = empty($site_specification) ? NULL : self::escapeshellarg($site_specification);
|
||||
$cmd[] = $command;
|
||||
if (in_array('--verbose', $_SERVER['argv'])) $args[] = '--verbose';
|
||||
if (in_array('--debug', $_SERVER['argv'])) $args[] = '--debug';
|
||||
|
||||
foreach ($args as $arg) {
|
||||
$cmd[] = self::escapeshellarg($arg);
|
||||
}
|
||||
$options['nocolor'] = NULL;
|
||||
foreach ($options as $key => $value) {
|
||||
if (is_null($value)) {
|
||||
$cmd[] = "--$key";
|
||||
}
|
||||
else {
|
||||
$cmd[] = "--$key=" . self::escapeshellarg($value);
|
||||
}
|
||||
}
|
||||
$exec = array_filter($cmd, 'strlen'); // Remove NULLs
|
||||
return $this->execute(implode(' ', $exec));
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for the last output.
|
||||
* @return string Output as text.
|
||||
* @access public
|
||||
*/
|
||||
function getOutput() {
|
||||
return implode("\n", $this->_output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for the last output.
|
||||
* @return array Output as array of lines.
|
||||
* @access public
|
||||
*/
|
||||
function getOutputAsList() {
|
||||
return $this->_output;
|
||||
}
|
||||
|
||||
function setUpDrupal($env = 'dev', $install = FALSE, $version_string = '7.x', $profile = NULL) {
|
||||
$root = UNISH_SANDBOX . '/web';
|
||||
$this->sites[$env]['root'] = $root;
|
||||
$site = "$root/sites/$env";
|
||||
if (is_null($profile)) {
|
||||
$profile = substr($version_string, 0, 1) >= 7 ? 'testing' : 'default';
|
||||
}
|
||||
|
||||
// Download Drupal if not already present.
|
||||
if (!file_exists($root)) {
|
||||
$options = array(
|
||||
'destination' => UNISH_SANDBOX,
|
||||
'drupal-project-rename' => 'web',
|
||||
'yes' => NULL,
|
||||
'quiet' => NULL,
|
||||
);
|
||||
$this->drush('pm-download', array("drupal-$version_string"), $options);
|
||||
}
|
||||
|
||||
// If specified, install Drupal as a multi-site.
|
||||
if ($install) {
|
||||
$options = array(
|
||||
'root' => $root,
|
||||
'db-url' => UNISH_DB_URL . '/unish_' . $env,
|
||||
'sites-subdir' => $env,
|
||||
'yes' => NULL,
|
||||
'quiet' => NULL,
|
||||
);
|
||||
$this->drush('site-install', array($profile), $options);
|
||||
// Give us our write perms back.
|
||||
$ret = chmod($site, 0777);
|
||||
|
||||
// Stash the db_url for this site.
|
||||
$this->sites[$env]['db_url'] = UNISH_DB_URL . '/unish_' . $env;
|
||||
}
|
||||
else {
|
||||
mkdir($site);
|
||||
touch("$site/settings.php");
|
||||
}
|
||||
// Make an alias for the site
|
||||
$alias_definition = array($env => array('root' => $root, 'uri' => $env));
|
||||
file_put_contents(UNISH_SANDBOX . '/etc/drush/' . $env . '.alias.drushrc.php', $this->file_aliases($alias_definition));
|
||||
}
|
||||
|
||||
// Copied from D7 - profiles/standard/standard.install
|
||||
function create_node_types_php() {
|
||||
$php = "
|
||||
\$types = array(
|
||||
array(
|
||||
'type' => 'page',
|
||||
'name' => 'Basic page',
|
||||
'base' => 'node_content',
|
||||
'description' => 'Use <em>basic pages</em> for your static content, such as an \'About us\' page.',
|
||||
'custom' => 1,
|
||||
'modified' => 1,
|
||||
'locked' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
'base' => 'node_content',
|
||||
'description' => 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.',
|
||||
'custom' => 1,
|
||||
'modified' => 1,
|
||||
'locked' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
foreach (\$types as \$type) {
|
||||
\$type = node_type_set_defaults(\$type);
|
||||
node_type_save(\$type);
|
||||
node_add_body_field(\$type);
|
||||
}
|
||||
";
|
||||
return $php;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare the contents of an aliases file.
|
||||
*/
|
||||
function file_aliases($aliases) {
|
||||
foreach ($aliases as $name => $alias) {
|
||||
$records[] = sprintf('$aliases[\'%s\'] = %s;', $name, var_export($alias, TRUE));
|
||||
}
|
||||
$contents = "<?php\n\n" . implode("\n\n", $records);
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same code as drush_delete_dir().
|
||||
* @see drush_delete_dir()
|
||||
*
|
||||
* @param string $dir
|
||||
* @return boolean
|
||||
*/
|
||||
function file_delete_recursive($dir) {
|
||||
if (!file_exists($dir)) {
|
||||
return TRUE;
|
||||
}
|
||||
if (!is_dir($dir)) {
|
||||
@chmod($dir, 0777); // Make file writeable
|
||||
return unlink($dir);
|
||||
}
|
||||
foreach (scandir($dir) as $item) {
|
||||
if ($item == '.' || $item == '..') {
|
||||
continue;
|
||||
}
|
||||
if (!self::file_delete_recursive($dir.'/'.$item)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize our environment at he start of each run (i.e. suite).
|
||||
*/
|
||||
function unish_init() {
|
||||
// We read from globals here because env can be empty and ini did not work in quick test.
|
||||
define('UNISH_DB_URL', getenv('UNISH_DB_URL') ? getenv('UNISH_DB_URL') : !empty($GLOBALS['UNISH_DB_URL']) ? $GLOBALS['UNISH_DB_URL'] : 'mysql://root:@127.0.0.1');
|
||||
|
||||
// UNISH_DRUSH value can come from phpunit.xml or `which drush`.
|
||||
if (!defined('UNISH_DRUSH')) {
|
||||
// Let the UNISH_DRUSH environment variable override if set.
|
||||
$unish_drush = isset($_SERVER['UNISH_DRUSH']) ? $_SERVER['UNISH_DRUSH'] : NULL;
|
||||
$unish_drush = isset($GLOBALS['UNISH_DRUSH']) ? $GLOBALS['UNISH_DRUSH'] : $unish_drush;
|
||||
if (empty($unish_drush)) {
|
||||
$unish_drush = Drush_TestCase::is_windows() ? exec('for %i in (drush) do @echo. %~$PATH:i') : trim(`which drush`);
|
||||
}
|
||||
define('UNISH_DRUSH', $unish_drush);
|
||||
}
|
||||
|
||||
define('UNISH_TMP', getenv('UNISH_TMP') ? getenv('UNISH_TMP') : (isset($GLOBALS['UNISH_TMP']) ? $GLOBALS['UNISH_TMP'] : sys_get_temp_dir()));
|
||||
define('UNISH_SANDBOX', UNISH_TMP . '/drush-sandbox');
|
||||
|
||||
$home = UNISH_SANDBOX . '/home';
|
||||
putenv("HOME=$home");
|
||||
putenv("HOMEDRIVE=$home");
|
||||
|
||||
putenv('ETC_PREFIX=' . UNISH_SANDBOX);
|
||||
putenv('SHARE_PREFIX=' . UNISH_SANDBOX);
|
||||
|
||||
// Cache dir lives outside the sandbox so that we get persistence across classes.
|
||||
$cache = UNISH_TMP . '/drush_cache';
|
||||
putenv("CACHE_PREFIX=" . $cache);
|
||||
// Wipe at beginning of run.
|
||||
if (file_exists($cache)) {
|
||||
unish_file_delete_recursive($cache);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same code as drush_delete_dir().
|
||||
* @see drush_delete_dir()
|
||||
*
|
||||
* @param string $dir
|
||||
* @return boolean
|
||||
*/
|
||||
function unish_file_delete_recursive($dir) {
|
||||
if (!file_exists($dir)) {
|
||||
return TRUE;
|
||||
}
|
||||
if (!is_dir($dir)) {
|
||||
@chmod($dir, 0777); // Make file writeable
|
||||
return unlink($dir);
|
||||
}
|
||||
foreach (scandir($dir) as $item) {
|
||||
if ($item == '.' || $item == '..') {
|
||||
continue;
|
||||
}
|
||||
if (!unish_file_delete_recursive($dir.'/'.$item)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return rmdir($dir);
|
||||
}
|
||||
|
||||
// This code is in global scope.
|
||||
// TODO: I would rather this code at top of file, but I get Fatal error: Class 'Drush_TestCase' not found
|
||||
unish_init();
|
||||
61
sites/all/modules/drush/tests/fieldTest.php
Normal file
61
sites/all/modules/drush/tests/fieldTest.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for field.drush.inc
|
||||
*/
|
||||
class fieldCase extends Drush_TestCase {
|
||||
|
||||
public function testField() {
|
||||
$this->setUpDrupal('dev', TRUE);
|
||||
$options = array(
|
||||
'yes' => NULL,
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
);
|
||||
// Create two field instances on article content type.
|
||||
$this->drush('field-create', array('user', 'city,text,text_textfield', 'subtitle,text,text_textfield'), $options + array('entity_type' => 'user'));
|
||||
$output = $this->getOutput();
|
||||
list($city, $subtitle) = explode(' ', $output);
|
||||
$url = parse_url($subtitle);
|
||||
$this->assertEquals('/admin/config/people/accounts/fields/subtitle', $url['path']);
|
||||
|
||||
// Assure that the second field instance was created correctly (subtitle).
|
||||
$this->verifyInstance('subtitle', $options);
|
||||
|
||||
// Assure that field update URL looks correct.
|
||||
$this->drush('field-update', array('subtitle'), $options);
|
||||
$output = $this->getOutput();
|
||||
$url = parse_url($this->getOutput());
|
||||
$this->assertEquals('/admin/config/people/accounts/fields/subtitle', $url['path']);
|
||||
|
||||
// Assure that field-clone actually clones.
|
||||
$this->drush('field-clone', array('subtitle', 'subtitlecloned'), $options);
|
||||
$this->verifyInstance('subtitlecloned', $options);
|
||||
|
||||
// Assure that delete works.
|
||||
$this->drush('field-delete', array('subtitlecloned'), $options);
|
||||
$this->verifyInstance('subtitlecloned', $options, FALSE);
|
||||
}
|
||||
|
||||
function verifyInstance($name, $options, $expected = TRUE) {
|
||||
$this->drush('field-info', array('fields'), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutputAsList();
|
||||
$found = FALSE;
|
||||
foreach($output as $row) {
|
||||
$columns = explode(',', $row);
|
||||
if ($columns[0] == $name) {
|
||||
$this->assertEquals('text', $columns[1], $name . ' field is of type=text.');
|
||||
$this->assertEquals('user', $columns[2], $name . ' field was added to user bundle.');
|
||||
$found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($expected) {
|
||||
$this->assertTrue($found, $name . ' field was created.');
|
||||
}
|
||||
else {
|
||||
$this->assertFalse($found, $name . ' field was not present.');
|
||||
}
|
||||
}
|
||||
}
|
||||
23
sites/all/modules/drush/tests/phpunit.xml.dist
Normal file
23
sites/all/modules/drush/tests/phpunit.xml.dist
Normal file
@@ -0,0 +1,23 @@
|
||||
<!-- Copy and rename to phpunit.xml. Customize as needed. -->
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="drush_testcase.inc">
|
||||
<php>
|
||||
<!-- These variables may alternatively be set as bash environment variables. -->
|
||||
|
||||
<!--Uncomment and edit one of the lines below depending on DB platform.-->
|
||||
<!--DB User must have create/drop permissions-->
|
||||
<!-- <var name="UNISH_DB_URL" value="mysql://root:@127.0.0.1"/> -->
|
||||
<!-- <var name="UNISH_DB_URL" value="pgsql://postgres:@localhost"/>-->
|
||||
|
||||
<!--User must have write permissions to this directory.-->
|
||||
<!--If not supplied, defaults to sys_get_tmp_dir().-->
|
||||
<!-- <var name="UNISH_TMP" value="/tmp"/> -->
|
||||
|
||||
<!--Uncomment the line below if your path to drush differs from `which drush`. Use absolute path.-->
|
||||
<!--<var name="UNISH_DRUSH" value="/Users/mw/bin/drush"/>-->
|
||||
|
||||
<includePath>.</includePath>
|
||||
</php>
|
||||
</phpunit>
|
||||
78
sites/all/modules/drush/tests/pmDownloadTest.php
Normal file
78
sites/all/modules/drush/tests/pmDownloadTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* pm-download testing
|
||||
*/
|
||||
class pmDownloadCase extends Drush_TestCase {
|
||||
public function testPmDownload() {
|
||||
$this->drush('pm-download', array('devel'));
|
||||
$this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse Drupal version and release from command argument.
|
||||
*
|
||||
* --dev option bypasses the logic tested here.
|
||||
*
|
||||
* @see pm_parse_project_version().
|
||||
*/
|
||||
public function testVersionString() {
|
||||
$eval = 'print json_encode(pm_parse_project_version(array("devel-6.x-1.18")));';
|
||||
$this->drush('php-eval', array($eval));
|
||||
$request_data = json_decode($this->getOutput());
|
||||
$this->assertObjectHasAttribute('devel', $request_data);
|
||||
$this->assertEquals($request_data->devel->drupal_version, '6.x');
|
||||
$this->assertEquals($request_data->devel->project_version, '1.18');
|
||||
}
|
||||
|
||||
/*
|
||||
* Pick right release from the XML (dev, latest published+recommended, ...).
|
||||
*/
|
||||
public function testReleaseXML() {
|
||||
// Use a local, static XML file because live files change over time.
|
||||
$xml = dirname(__FILE__). '/devel.xml';
|
||||
|
||||
// Pick specific release.
|
||||
$request_data = array(
|
||||
'name' => 'devel',
|
||||
'drupal_version' => '6.x',
|
||||
'project_version' => '1.18',
|
||||
'version' => '6.x-1.18',
|
||||
);
|
||||
// Build an $eval string for use with php-eval in a subprocess.
|
||||
$eval = '$request_data = ' . var_export($request_data, TRUE) . ";\n";
|
||||
$eval .= '$release = pm_parse_release($request_data, simplexml_load_file(\'' . $xml . "'));\n";
|
||||
$eval .= 'print json_encode($release);';
|
||||
$this->drush('php-eval', array($eval));
|
||||
$release = json_decode($this->getOutput());
|
||||
$this->assertEquals($release->version, '6.x-1.18');
|
||||
|
||||
// Pick latest recommended+published with no further specification.
|
||||
// 6.x-2.2 is skipped because it is unpublished.
|
||||
// 6.x-2.2-rc1 is skipped because it is not a stable release.
|
||||
// Remove unwanted $request_data items.
|
||||
$eval = str_replace(array("'project_version' => '1.18',\n", "'version' => '6.x-1.18',\n"), NULL, $eval);
|
||||
$this->drush('php-eval', array($eval));
|
||||
$release = json_decode($this->getOutput());
|
||||
$this->assertEquals($release->version, '6.x-2.1');
|
||||
}
|
||||
|
||||
// @todo Test pure drush commandfile projects. They get special destination.
|
||||
public function testDestination() {
|
||||
// Setup first Drupal site. Skip install for speed.
|
||||
$this->setUpDrupal('dev', FALSE);
|
||||
$root = $this->sites['dev']['root'];
|
||||
|
||||
// Default to sites/all
|
||||
$this->drush('pm-download', array('devel'), array('root' => $root));
|
||||
$this->assertFileExists($root . '/sites/all/modules/devel/README.txt');
|
||||
|
||||
// If we are in site specific dir, then download belongs there.
|
||||
// Setup a second site. Skip install for speed.
|
||||
$this->setUpDrupal('stage', FALSE);
|
||||
$path_stage = "$root/sites/stage";
|
||||
mkdir("$path_stage/modules");
|
||||
$this->drush('pm-download', array('devel'), array(), NULL, $path_stage);
|
||||
$this->assertFileExists($path_stage . '/modules/devel/README.txt');
|
||||
}
|
||||
}
|
||||
53
sites/all/modules/drush/tests/pmEnDisUnListTest.php
Normal file
53
sites/all/modules/drush/tests/pmEnDisUnListTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for enable, disable, uninstall, pm-list commands.
|
||||
*/
|
||||
|
||||
class EnDisUnListCase extends Drush_TestCase {
|
||||
|
||||
public function testEnDisUnList() {
|
||||
$this->setUpDrupal('dev', TRUE);
|
||||
$options = array(
|
||||
'yes' => NULL,
|
||||
'pipe' => NULL,
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
);
|
||||
$this->drush('pm-download', array('devel-7.x-1.0'), $options);
|
||||
$this->drush('pm-list', array(), $options + array('no-core' => NULL, 'status' => 'not installed'));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->assertTrue(in_array('devel', $list));
|
||||
|
||||
$this->drush('pm-enable', array('menu', 'devel'), $options);
|
||||
$this->drush('pm-list', array(), $options + array('status' => 'enabled'));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->assertTrue(in_array('devel', $list));
|
||||
$this->assertTrue(in_array('bartik', $list), 'Themes are in the pm-list');
|
||||
|
||||
$this->drush('pm-list', array(), $options + array('package' => 'Core'));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->assertFalse(in_array('devel', $list), 'Devel is not part of core package');
|
||||
|
||||
// For testing uninstall later.
|
||||
$this->drush('variable-set', array('devel_query_display', 1), $options);
|
||||
|
||||
$this->drush('pm-disable', array('devel'), $options);
|
||||
$this->drush('pm-list', array(), $options + array('status' => 'disabled'));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->assertTrue(in_array('devel', $list));
|
||||
|
||||
$this->drush('pm-uninstall', array('devel'), $options);
|
||||
$this->drush('pm-list', array(), $options + array('status' => 'not installed', 'type' => 'module'));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->assertTrue(in_array('devel', $list));
|
||||
|
||||
|
||||
// We expect an exit code of 1 so just call execute() directly.
|
||||
$exec = sprintf('%s variable-get %s --pipe --root=%s --uri=%s', UNISH_DRUSH, 'devel_query_display', $options['root'], $options['uri']);
|
||||
$this->execute($exec, self::EXIT_ERROR);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEmpty($output, 'Devel variable was uninstalled.');
|
||||
}
|
||||
}
|
||||
72
sites/all/modules/drush/tests/pmUpdateCodeTest.php
Normal file
72
sites/all/modules/drush/tests/pmUpdateCodeTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Prepare a codebase and upgrade it in several stages, exercising
|
||||
* updatecode's filters.
|
||||
* @todo test security-only once one of these modules or core gets a security release.
|
||||
*/
|
||||
|
||||
class pmUpdateCode extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Download old core and older contrib releases which will always need updating.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->setUpDrupal('dev', TRUE, '7.0-rc3');
|
||||
$options = array(
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
'yes' => NULL,
|
||||
'quiet' => NULL,
|
||||
);
|
||||
$this->drush('pm-download', array('devel-7.x-1.0-rc1,webform-7.x-3.4-beta1'), $options);
|
||||
$this->drush('pm-enable', array('menu', 'devel', 'webform'), $options);
|
||||
}
|
||||
|
||||
function testUpdateCode() {
|
||||
$options = array(
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
'yes' => NULL,
|
||||
'backup-dir' => UNISH_SANDBOX . '/backups',
|
||||
'self-update' => 0, // Don't try update Drush.
|
||||
);
|
||||
|
||||
// Try to upgrade a specific module.
|
||||
$this->drush('pm-updatecode', array('devel'), $options + array());
|
||||
// Assure that devel was upgraded and webform was not.
|
||||
$this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
|
||||
$all = $this->getOutput();
|
||||
$this->assertNotContains('devel', $all);
|
||||
$this->assertContains('webform', $all);
|
||||
|
||||
// Lock webform, and update core.
|
||||
$this->drush('pm-updatecode', array(), $options + array('lock' => 'webform'));
|
||||
$list = $this->getOutputAsList(); // For debugging.
|
||||
$this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
|
||||
$all = $this->getOutput();
|
||||
$this->assertNotContains('drupal', $all, 'Core was updated');
|
||||
$this->assertContains('webform', $all, 'Webform was skipped.');
|
||||
|
||||
// Unlock webform, update, and check.
|
||||
$this->drush('pm-updatecode', array(), $options + array('unlock' => 'webform', 'no-backup' => NULL));
|
||||
$list = $this->getOutputAsList();
|
||||
$this->drush('pm-updatecode', array(), $options + array('pipe' => NULL));
|
||||
$all = $this->getOutput();
|
||||
$this->assertNotContains('webform', $all, 'Webform was updated');
|
||||
|
||||
// Verify that we keep backups as instructed.
|
||||
$pattern = 'find %s -iname %s';
|
||||
$backup_dir = UNISH_SANDBOX . '/backups';
|
||||
$cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('devel.module'));
|
||||
$this->execute($cmd);
|
||||
$output = $this->getOutput();
|
||||
$this->assertNotEmpty($output);
|
||||
|
||||
$cmd = sprintf($pattern, self::escapeshellarg($backup_dir), escapeshellarg('webform.module'));
|
||||
$this->execute($cmd);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEmpty($output);
|
||||
}
|
||||
}
|
||||
25
sites/all/modules/drush/tests/runner.php
Normal file
25
sites/all/modules/drush/tests/runner.php
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A nearly verbatim copy of phpunit script that ships with PEAR's PHPUnit.
|
||||
*/
|
||||
|
||||
require_once 'PHP/CodeCoverage/Filter.php';
|
||||
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');
|
||||
|
||||
if (extension_loaded('xdebug')) {
|
||||
// Drush comments out the following line for easier debugging.
|
||||
// xdebug_disable();
|
||||
}
|
||||
|
||||
if (strpos('/usr/bin/php', '@php_bin') === 0) {
|
||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
|
||||
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
|
||||
|
||||
PHPUnit_TextUI_Command::main();
|
||||
30
sites/all/modules/drush/tests/siteAliasTest.php
Normal file
30
sites/all/modules/drush/tests/siteAliasTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for sitealias.inc
|
||||
*/
|
||||
class saCase extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Assure that site lists work as expected.
|
||||
* @todo Use --backend for structured return data. Depends on http://drupal.org/node/1043922
|
||||
*/
|
||||
public function testSAList() {
|
||||
$this->setUpDrupal('dev');
|
||||
$this->setUpDrupal('stage');
|
||||
$eval = 'print "bon";';
|
||||
$options = array(
|
||||
'yes' => NULL,
|
||||
'root' => $this->sites['dev']['root'],
|
||||
);
|
||||
$this->drush('php-eval', array($eval), $options, "#dev,#stage");
|
||||
$expected = "You are about to execute 'php-eval print \"bon\";' on all of the following targets:
|
||||
#dev
|
||||
#stage
|
||||
Continue? (y/n): y
|
||||
#dev >> bon
|
||||
#stage >> bon";
|
||||
$this->assertEquals($expected, $this->getOutput());
|
||||
}
|
||||
}
|
||||
71
sites/all/modules/drush/tests/siteUpgradeTest.php
Normal file
71
sites/all/modules/drush/tests/siteUpgradeTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Programmatically upgrade a site from Drupal 6 to Druapl 7.
|
||||
*
|
||||
* We also implicitly test:
|
||||
* - pm-download
|
||||
* - site-install for D6
|
||||
* - user-create
|
||||
* - sql-sync
|
||||
* - updatedb and batch.inc
|
||||
*/
|
||||
|
||||
class siteUpgradeCase extends Drush_TestCase {
|
||||
function testUpgrade() {
|
||||
$env = 'testupgrade';
|
||||
$this->setUpDrupal($env, TRUE, '6.x');
|
||||
$root = $this->sites[$env]['root'];
|
||||
|
||||
// Create the alias for D7 site.
|
||||
$aliases['target'] = array(
|
||||
'root' => UNISH_SANDBOX . '/target',
|
||||
'uri' => $env,
|
||||
'db-url' => UNISH_DB_URL . '/unish_target',
|
||||
);
|
||||
$contents = $this->file_aliases($aliases);
|
||||
$alias_path = "$root/aliases.drushrc.php";
|
||||
file_put_contents($alias_path, $contents);
|
||||
|
||||
// Create a user in D6.
|
||||
$name = "example";
|
||||
$options = array(
|
||||
'mail' => "example@example.com",
|
||||
'password' => 'password',
|
||||
'root' => $root,
|
||||
'uri' => $env,
|
||||
);
|
||||
$this->drush('user-create', array($name), $options);
|
||||
|
||||
// Perform the upgrade.
|
||||
$options = array(
|
||||
'yes' => NULL,
|
||||
'root' => $root,
|
||||
'uri' => $env,
|
||||
);
|
||||
$this->drush('site-upgrade', array('@target'), $options);
|
||||
|
||||
// Assert that the D7 site bootstraps.
|
||||
// We don't specify @target alias since that file is in the root of the *source* site.
|
||||
$options = array(
|
||||
'pipe' => NULL,
|
||||
'root' => $aliases['target']['root'],
|
||||
'uri' => $aliases['target']['uri'],
|
||||
);
|
||||
$return = $this->drush('core-status', array('drupal_bootstrap'), $options);
|
||||
$this->assertEquals('Successful', $this->getOutput(), 'The target site bootstraps successfully');
|
||||
|
||||
// Assures that a updatedb and batch updates work properly. See user_update_7001().
|
||||
$options = array(
|
||||
'root' => $aliases['target']['root'],
|
||||
'uri' => $aliases['target']['uri'],
|
||||
);
|
||||
$eval = "require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');";
|
||||
$eval .= "\$account = user_load_by_name('example');";
|
||||
$eval .= "print (string) user_check_password('password', \$account)";
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertSame('1', $output, 'User was updated to new password format.');
|
||||
}
|
||||
}
|
||||
65
sites/all/modules/drush/tests/sqlSyncTest.php
Normal file
65
sites/all/modules/drush/tests/sqlSyncTest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* For now we only test sql-sync in simulated mode.
|
||||
*
|
||||
* Future: Using two copies of Drupal, we could test
|
||||
* overwriting one site with another.
|
||||
*/
|
||||
|
||||
class sqlSyncTest extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Covers the following responsibilities.
|
||||
* - A user created on the source site is copied to the destination site.
|
||||
* - The email address of the copied user is sanitized on the destination site.
|
||||
*
|
||||
* General handling of site aliases will be in sitealiasTest.php.
|
||||
*/
|
||||
public function testLocalSqlSync() {
|
||||
$this->setUpDrupal('dev', TRUE);
|
||||
$this->setUpDrupal('stage', TRUE);
|
||||
$dump_dir = UNISH_SANDBOX . "/dump-dir";
|
||||
mkdir($dump_dir);
|
||||
|
||||
// Create a user in the staging site
|
||||
$name = 'joe.user';
|
||||
$mail = "joe.user@myhome.com";
|
||||
$options = array(
|
||||
'root' => $this->sites['stage']['root'],
|
||||
'uri' => 'stage',
|
||||
'yes' => NULL,
|
||||
);
|
||||
$this->drush('user-create', array($name), $options + array('password' => 'password', 'mail' => $mail));
|
||||
|
||||
// Copy stage to dev with --sanitize
|
||||
$sync_options = array(
|
||||
'sanitize' => NULL,
|
||||
'yes' => NULL,
|
||||
'dump-dir' => $dump_dir
|
||||
);
|
||||
$this->drush('sql-sync', array('@stage', '@dev'), $sync_options);
|
||||
|
||||
// Confirm that the sample user has the correct email address on the staging site
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$uid = $row[1];
|
||||
$this->assertEquals($mail, $row[2], 'email address is unchanged on source site.');
|
||||
$this->assertEquals($name, $row[0]);
|
||||
|
||||
$options = array(
|
||||
'root' => $this->sites['dev']['root'],
|
||||
'uri' => 'dev',
|
||||
'yes' => NULL,
|
||||
);
|
||||
// Confirm that the sample user's email address has been sanitized on the dev site
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$uid = $row[1];
|
||||
$this->assertEquals("user+2@localhost", $row[2], 'email address was sanitized on destination site.');
|
||||
$this->assertEquals($name, $row[0]);
|
||||
}
|
||||
}
|
||||
76
sites/all/modules/drush/tests/unit.drush.inc
Normal file
76
sites/all/modules/drush/tests/unit.drush.inc
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Commands which are useful for unit tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_drush_command().
|
||||
*/
|
||||
function unit_drush_command() {
|
||||
$items['unit-eval'] = array(
|
||||
'description' => 'Works like php-eval. Used for testing $command_specific context.',
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_MAX,
|
||||
'callback' => 'drush_core_php_eval', // Note - no invoke hooks.
|
||||
);
|
||||
$items['unit-invoke'] = array(
|
||||
'description' => 'Return an array indicating which invoke hooks got called.',
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_NONE,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dynamically append custom bash code to the generated .bashrc.
|
||||
*
|
||||
* @see coreCase::testCoreCLI().
|
||||
*/
|
||||
function unit_cli_bashrc($drush_command, $interactive_mode) {
|
||||
return drush_get_option('unit-extra');
|
||||
}
|
||||
|
||||
// Implement each invoke hook with the same single line of code.
|
||||
// That line records that the hook was called.
|
||||
function drush_unit_invoke_init() {unit_invoke_log(__FUNCTION__);}
|
||||
function drush_unit_invoke_validate() {unit_invoke_log(__FUNCTION__);}
|
||||
function drush_unit_pre_unit_invoke() {unit_invoke_log(__FUNCTION__);}
|
||||
function drush_unit_invoke() {unit_invoke_log(__FUNCTION__);}
|
||||
function drush_unit_pre_unit_invoke_rollback() {unit_invoke_log(__FUNCTION__);}
|
||||
function drush_unit_post_unit_invoke_rollback() {unit_invoke_log(__FUNCTION__);}
|
||||
|
||||
// Record that hook_drush_init() fired.
|
||||
function unit_drush_init() {
|
||||
$command = drush_get_command();
|
||||
if ($command['command'] == 'unit-invoke') {
|
||||
unit_invoke_log(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
function drush_unit_post_unit_invoke() {
|
||||
// Record that this hook was called.
|
||||
unit_invoke_log(__FUNCTION__);
|
||||
|
||||
// Make sure we enter into rollback.
|
||||
drush_set_error('');
|
||||
}
|
||||
|
||||
/*
|
||||
* The final invoke hook. Emit the call history.
|
||||
* Cannot use 'exit' as it does not fire in rollback scenario.
|
||||
*/
|
||||
function drush_unit_invoke_validate_rollback() {
|
||||
unit_invoke_log(__FUNCTION__);
|
||||
print json_encode(unit_invoke_log());
|
||||
}
|
||||
|
||||
function unit_invoke_log($function = NULL) {
|
||||
static $called = array();
|
||||
if ($function) {
|
||||
$called[] = $function;
|
||||
}
|
||||
else {
|
||||
return $called;
|
||||
}
|
||||
}
|
||||
103
sites/all/modules/drush/tests/userTest.php
Normal file
103
sites/all/modules/drush/tests/userTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for user.drush.inc
|
||||
*/
|
||||
class userCase extends Drush_TestCase {
|
||||
|
||||
/*
|
||||
* Create, edit, block, and cancel users.
|
||||
*/
|
||||
public function testUser() {
|
||||
// user-create
|
||||
$env = 'dev';
|
||||
$this->setUpDrupal($env, TRUE);
|
||||
$root = $this->sites[$env]['root'];
|
||||
$name = "example";
|
||||
$options = array(
|
||||
'root' => $root,
|
||||
'uri' => $env,
|
||||
'yes' => NULL,
|
||||
);
|
||||
$this->drush('user-create', array($name), $options + array('password' => 'password', 'mail' => "example@example.com"));
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$uid = $row[1];
|
||||
$this->assertEquals('example@example.com', $row[2]);
|
||||
$this->assertEquals($name, $row[0]);
|
||||
$this->assertEquals(1, $row[3], 'Newly created user is Active.');
|
||||
$this->assertEquals('authenticated user', $row[4], 'Newly created user has one role.');
|
||||
|
||||
// user-block
|
||||
$this->drush('user-block', array($name), $options);
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$this->assertEquals(0, $row[3], 'User is blocked.');
|
||||
|
||||
// user-unblock
|
||||
$this->drush('user-unblock', array($name), $options);
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$this->assertEquals(1, $row[3], 'User is unblocked.');
|
||||
|
||||
// user-add-role
|
||||
// first, create the fole since we use testing install profile.
|
||||
$eval = "user_role_save((object)array('name' => 'administrator'))";
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$this->drush('user-add-role', array('administrator', $name), $options);
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$this->assertEquals('authenticated user, administrator', $row[4], 'User has administrator role.');
|
||||
|
||||
// user-remove-role
|
||||
$this->drush('user-remove-role', array('administrator', $name), $options);
|
||||
$this->drush('user-information', array($name), $options + array('pipe' => NULL));
|
||||
$output = $this->getOutput();
|
||||
$row = str_getcsv($output);
|
||||
$this->assertEquals('authenticated user', $row[4], 'User removed administrator role.');
|
||||
|
||||
// user-password
|
||||
$newpass = 'newpass';
|
||||
$this->drush('user-password', array($name), $options + array('password' => $newpass));
|
||||
$eval = "require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');";
|
||||
$eval .= "\$account = user_load_by_name('example');";
|
||||
$eval .= "print (string) user_check_password('$newpass', \$account)";
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEquals('1', $output, 'User can login with new password.');
|
||||
|
||||
// user-login
|
||||
$this->drush('user-login', array($name), $options);
|
||||
$output = $this->getOutput();
|
||||
$url = parse_url($output);
|
||||
$this->assertStringStartsWith('/user/reset/' . $uid, $url['path'], 'Login returned a valid reset URL');
|
||||
|
||||
// user-cancel
|
||||
// create content
|
||||
$eval = $this->create_node_types_php();
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$eval = "
|
||||
\$node = (object) array(
|
||||
'title' => 'foo',
|
||||
'uid' => 2,
|
||||
'type' => 'page',
|
||||
);
|
||||
node_save(\$node);
|
||||
";
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$this->drush('user-cancel', array($name), $options + array('delete-content' => NULL));
|
||||
$eval = 'print (string) user_load(2)';
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEmpty($output, 'User was deleted');
|
||||
$eval = 'print (string) node_load(2)';
|
||||
$this->drush('php-eval', array($eval), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEmpty($output, 'Content was deleted');
|
||||
}
|
||||
}
|
||||
35
sites/all/modules/drush/tests/variableTest.php
Normal file
35
sites/all/modules/drush/tests/variableTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Tests for enable, disable, uninstall, pm-list commands.
|
||||
*/
|
||||
class VariableCase extends Drush_TestCase {
|
||||
|
||||
function testVariable() {
|
||||
$env = 'dev';
|
||||
$this->setUpDrupal($env, TRUE);
|
||||
$options = array(
|
||||
'yes' => NULL,
|
||||
'pipe' => NULL,
|
||||
'root' => $this->sites[$env]['root'],
|
||||
'uri' => $env,
|
||||
);
|
||||
|
||||
$this->drush('variable-set', array('date_default_timezone', 'US/Mountain'), $options);
|
||||
$this->drush('variable-get', array('date_default_timezone'), $options); // Wildcard get.
|
||||
$var_export = $this->getOutput();
|
||||
eval($var_export);
|
||||
$this->assertEquals('US/Mountain', $variables['date_default_timezone'], 'Variable was successfully set and get.');
|
||||
|
||||
$this->drush('variable-set', array('site_name', 'unish'), $options + array('always-set' => NULL));
|
||||
$this->drush('variable-get', array('site_name'), $options);
|
||||
$var_export = $this->getOutput();
|
||||
eval($var_export);
|
||||
$this->assertEquals('unish', $variables['site_name'], '--always-set option works as expected.');
|
||||
|
||||
$this->drush('variable-delete', array('site_name'), $options);
|
||||
$output = $this->getOutput();
|
||||
$this->assertEmpty($output, 'Variable was successfully deleted.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user