class sqlSyncTest
- 6.x tests/sqlSyncTest.php sqlSyncTest
- 5.x tests/sqlSyncTest.php sqlSyncTest
- 4.x tests/sqlSyncTest.php sqlSyncTest
Hierarchy
- class Drush_TestCase extends \PHPUnit_Framework_TestCase
- class Drush_CommandTestCase
- class sqlSyncTest
- class Drush_CommandTestCase
Expanded class hierarchy of sqlSyncTest
Members
|
Name |
Modifiers | Type | Description |
|---|---|---|---|
| Drush_CommandTestCase::drush | function | Invoke drush in via execute(). | |
| Drush_CommandTestCase::drush_major_version | function | ||
| Drush_CommandTestCase::execute | function | Actually runs the command. Does not trap the error stream output as this need PHP 4.3+. | |
| Drush_CommandTestCase::EXIT_ERROR | constant | ||
| Drush_CommandTestCase::EXIT_SUCCESS | constant | ||
| Drush_CommandTestCase::file_aliases | function | ||
| Drush_TestCase::bit_bucket | function | Borrowed from Drush. Checks operating system and returns supported bit bucket folder. | |
| Drush_TestCase::convert_path | function | Converts a Windows path (dir1\dir2\dir3) into a Unix path (dir1/dir2/dir3). Also converts a cygwin "drive emulation" path (/cygdrive/c/dir1) into a proper drive path, still with Unix slashes (c:/dir1). | |
| Drush_TestCase::db_url | function | ||
| Drush_TestCase::directory_cache | function | ||
| Drush_TestCase::escapeshellarg | public static | function | |
| Drush_TestCase::fetchInstallDrupal | function | ||
| Drush_TestCase::getOutput | function | Accessor for the last output. | |
| Drush_TestCase::getOutputAsList | function | Accessor for the last output. | |
| Drush_TestCase::get_tar_executable | public static | function | |
| Drush_TestCase::is_windows | public static | function | |
| Drush_TestCase::log | function | Print a log message to the console. | |
| Drush_TestCase::log_level | function | ||
| Drush_TestCase::randomString | public | function | Helper function to generate a random string of arbitrary length. |
| Drush_TestCase::setUpBeforeClass | public static | function | Assure that each class starts with an empty sandbox directory and a clean environment - http://drupal.org/node/1103568. |
| Drush_TestCase::setUpDrupal | function | ||
| Drush_TestCase::setUpFreshSandBox | public static | function | Remove any pre-existing sandbox, then create a new one. |
| Drush_TestCase::tearDownAfterClass | public static | function | Runs after all tests in a class are run. Remove sandbox directory. |
| Drush_TestCase::webroot | function | ||
| Drush_TestCase::_escapeshellarg_windows | public static | function | |
| Drush_TestCase::__construct | function | ||
| sqlSyncTest::localSqlSync | public | function | |
| sqlSyncTest::testLocalSqlSync | public | function | |
| sqlSyncTest::testLocalSqlSyncD6 | public | function | Do the same test as above, but use Drupal 6 sites instead of Drupal 7. |
File
- tests/
sqlSyncTest.php, line 15
View source
class sqlSyncTest extends Drush_CommandTestCase {
/*
* 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() {
if (strpos(UNISH_DB_URL, 'sqlite') !== FALSE) {
$this->markTestSkipped('SQL Sync does not apply to SQLite.');
return;
}
$sites = $this->setUpDrupal(2, TRUE);
return $this->localSqlSync();
}
/**
* Do the same test as above, but use Drupal 6 sites instead of Drupal 7.
*/
public function testLocalSqlSyncD6() {
if (UNISH_DRUPAL_MAJOR_VERSION != 6) {
$this->markTestSkipped('This test class is designed for Drupal 6.');
return;
}
chdir(UNISH_TMP); // Avoids perm denied Windows error.
$this->setUpBeforeClass();
$sites = $this->setUpDrupal(2, TRUE, '6');
return $this->localSqlSync();
}
public function localSqlSync() {
$dump_dir = UNISH_SANDBOX . "/dump-dir";
if (!is_dir($dump_dir)) {
mkdir($dump_dir);
}
// Create a user in the staging site
$name = 'joe.user';
$mail = "joe.user@myhome.com";
$options = array(
'root' => $this->webroot(),
'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->webroot(),
'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+$uid@localhost", $row[2], 'email address was sanitized on destination site.');
$this->assertEquals($name, $row[0]);
// Copy stage to dev with --sanitize and a fixed sanitized email
$sync_options = array(
'sanitize' => NULL,
'yes' => NULL,
'dump-dir' => $dump_dir,
'sanitize-email' => 'user@localhost',
);
$this->drush('sql-sync', array('@stage', '@dev'), $sync_options);
$options = array(
'root' => $this->webroot(),
'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@localhost", $row[2], 'email address was sanitized (fixed email) on destination site.');
$this->assertEquals($name, $row[0]);
}
}