Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions sut/drush/sites/sut.site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Aliases for the System Under Test (SUT)
#

# The 'common' section is added to every alias environment.
# - ${drush.base-dir} is the path where Drush is installed
# - ${env-name} is the name of the environment that this info
# is being injected in (e.g. 'dev', 'stage', etc.)
common:
root: ${drush.base-dir}/sut
dbUrl: 'mysql://root:@127.0.0.1/unish_${env-name}'

# The 'default' environment is used by the integration tests
default:
uri: default

# The 'dev' and 'stage' environments are used by the functional tests.
# 'prod' may be used for ad-hoc testing, or may be used in future tests.
dev:
uri: dev
stage:
uri: stage
prod:
uri: prod
14 changes: 14 additions & 0 deletions sut/drush/sites/synctest.site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
remote:
root: /Users/ganderson/local/drupal/drush9/drush/sut
uri: remote
dbUrl: 'mysql://root:@127.0.0.1/unish_remote'
host: server.isp.simulated
user: www-admin
ssh:
options: '-o PasswordAuthentication=whatever'
paths:
drush-script: /path/to/drush
local:
root: /Users/ganderson/local/drupal/drush9/drush/sut
uri: local
dbUrl: 'mysql://root:@127.0.0.1/unish_local'
45 changes: 18 additions & 27 deletions tests/unish/UnishTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static function cleanDirs()
}
$webrootSlashDrush = self::webrootSlashDrush();
if (file_exists($webrootSlashDrush)) {
self::recursiveDelete($webrootSlashDrush, true, false, ['Commands']);
self::recursiveDelete($webrootSlashDrush, true, false, ['Commands', 'sites']);
}
foreach (['modules', 'themes', 'profiles'] as $dir) {
$target = Path::join(self::webroot(), $dir, 'contrib');
Expand Down Expand Up @@ -523,7 +523,7 @@ public function setUpSettings(array $sites, $aliasGroup = 'fixture')
$this->createSettings($subdir);
}
// Create basic site alias data with root and uri
$siteAliasData = $this->createAliasFileData(array_keys($sites), $aliasGroup);
$siteAliasData = $this->aliasFileData(array_keys($sites), $aliasGroup);
// Add in caller-provided site alias data
$siteAliasData = array_merge_recursive($siteAliasData, $sites);
$this->writeSiteAliases($siteAliasData, $aliasGroup);
Expand Down Expand Up @@ -559,7 +559,7 @@ public function createSettings($subdir)
*/
public function setUpDrupal($num_sites = 1, $install = false, $options = [])
{
$sites_subdirs_all = ['dev', 'stage', 'prod', 'retired', 'elderly', 'dead', 'dust'];
$sites_subdirs_all = ['dev', 'stage', 'prod'];
$sites_subdirs = array_slice($sites_subdirs_all, 0, $num_sites);
$root = $this->webroot();

Expand All @@ -573,15 +573,15 @@ public function setUpDrupal($num_sites = 1, $install = false, $options = [])
copy($root . '/sites/example.sites.php', $root . '/sites/sites.php');
}

$siteData = $this->createAliasFile($sites_subdirs, 'sut');
$siteData = $this->aliasFileData($sites_subdirs);
self::$sites = [];
foreach ($siteData as $key => $data) {
self::$sites[$key] = $data;
}
return self::$sites;
}

public function createAliasFileData($sites_subdirs)
public function aliasFileData($sites_subdirs)
{
$root = $this->webroot();
// Stash details about each site.
Expand All @@ -596,13 +596,21 @@ public function createAliasFileData($sites_subdirs)
return $sites;
}

public function createAliasFile($sites_subdirs, $aliasGroup)
protected function sutAlias($uri = self::INTEGRATION_TEST_ENV)
{
// Make an alias group for the sites.
$sites = $this->createAliasFileData($sites_subdirs);
$this->writeSiteAliases($sites, $aliasGroup);
return new AliasRecord(['root' => $this->webroot(), 'uri' => $uri], "@sut.$uri");
}

return $sites;
/**
* Write an alias group file and a config file which points to same dir.
*
* @param $sites
*/
public function writeSiteAliases($sites, $aliasGroup = 'sut')
{
$target = Path::join(self::webrootSlashDrush(), "sites/$aliasGroup.site.yml");
$this->mkdir(dirname($target));
file_put_contents($target, Yaml::dump($sites, PHP_INT_MAX, 2));
}

/**
Expand All @@ -625,23 +633,6 @@ public function installDrupal($env = 'dev', $install = false, $options = [], $re
}
}

/**
* Write an alias group file and a config file which points to same dir.
*
* @param $sites
*/
public function writeSiteAliases($sites, $aliasGroup = 'sut')
{
$target = Path::join(self::webrootSlashDrush(), "sites/$aliasGroup.site.yml");
$this->mkdir(dirname($target));
file_put_contents($target, Yaml::dump($sites, PHP_INT_MAX, 2));
}

protected function sutAlias($uri = self::INTEGRATION_TEST_ENV)
{
return new AliasRecord(['root' => $this->webroot(), 'uri' => $uri], "@sut.$uri");
}

protected function checkInstallSut($uri = self::INTEGRATION_TEST_ENV)
{
$sutAlias = $this->sutAlias($uri);
Expand Down