Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
109
vendor/consolidation/site-alias/tests/SiteAliasCommandsTest.php
vendored
Normal file
109
vendor/consolidation/site-alias/tests/SiteAliasCommandsTest.php
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class ExampleCommandsTest extends TestCase
|
||||
{
|
||||
/** @var string[] */
|
||||
protected $commandClasses;
|
||||
|
||||
/** @var string */
|
||||
protected $appName;
|
||||
|
||||
/** @var string */
|
||||
protected $appVersion;
|
||||
|
||||
const STATUS_OK = 0;
|
||||
const STATUS_ERROR = 1;
|
||||
|
||||
/**
|
||||
* Instantiate a new runner
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
// Store the command classes we are going to test
|
||||
$this->commandClasses = [ \Consolidation\SiteAlias\Cli\SiteAliasCommands::class ];
|
||||
|
||||
// Define our invariants for our test
|
||||
$this->appName = 'TestFixtureApp';
|
||||
$this->appVersion = '1.0.1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testExample.
|
||||
*
|
||||
* Return an array of arrays, each of which contains the parameter
|
||||
* values to be used in one invocation of the testExample test function.
|
||||
*/
|
||||
public function exampleTestCommandParameters()
|
||||
{
|
||||
return [
|
||||
|
||||
[
|
||||
'Add search location: /fixtures/sitealiases/sites', self::STATUS_ERROR,
|
||||
'site:list', '/fixtures/sitealiases/sites',
|
||||
],
|
||||
|
||||
[
|
||||
'List available site aliases', self::STATUS_OK,
|
||||
'list',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test our example class. Each time this function is called, it will
|
||||
* be passed data from the data provider function idendified by the
|
||||
* dataProvider annotation.
|
||||
*
|
||||
* @dataProvider exampleTestCommandParameters
|
||||
*/
|
||||
public function testExampleCommands($expectedOutput, $expectedStatus, $variable_args)
|
||||
{
|
||||
// Create our argv array and run the command
|
||||
$argv = $this->argv(func_get_args());
|
||||
list($actualOutput, $statusCode) = $this->execute($argv);
|
||||
|
||||
// Confirm that our output and status code match expectations
|
||||
$this->assertContains($expectedOutput, $actualOutput);
|
||||
$this->assertEquals($expectedStatus, $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare our $argv array; put the app name in $argv[0] followed by
|
||||
* the command name and all command arguments and options.
|
||||
*/
|
||||
protected function argv($functionParameters)
|
||||
{
|
||||
$argv = $functionParameters;
|
||||
array_shift($argv);
|
||||
array_shift($argv);
|
||||
array_unshift($argv, $this->appName);
|
||||
|
||||
// TODO: replace paths beginning with '/fixtures' with actual path to fixture data
|
||||
|
||||
return $argv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulated front controller
|
||||
*/
|
||||
protected function execute($argv)
|
||||
{
|
||||
// Define a global output object to capture the test results
|
||||
$output = new BufferedOutput();
|
||||
|
||||
// We can only call `Runner::execute()` once; then we need to tear down.
|
||||
$runner = new \Robo\Runner($this->commandClasses);
|
||||
$statusCode = $runner->execute($argv, $this->appName, $this->appVersion, $output);
|
||||
\Robo\Robo::unsetContainer();
|
||||
|
||||
// Return the output and status code.
|
||||
$actualOutput = trim($output->fetch());
|
||||
return [$actualOutput, $statusCode];
|
||||
}
|
||||
}
|
70
vendor/consolidation/site-alias/tests/SiteAliasFileDiscoveryTest.php
vendored
Normal file
70
vendor/consolidation/site-alias/tests/SiteAliasFileDiscoveryTest.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteAliasFileDiscoveryTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
use FunctionUtils;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
$this->sut = new SiteAliasFileDiscovery();
|
||||
}
|
||||
|
||||
public function testSearchForSingleAliasFile()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
$path = $this->sut->findSingleSiteAliasFile('single');
|
||||
$this->assertLocation('sites', $path);
|
||||
$this->assertBasename('single.site.yml', $path);
|
||||
}
|
||||
|
||||
public function testSearchForMissingSingleAliasFile()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
$path = $this->sut->findSingleSiteAliasFile('missing');
|
||||
$this->assertFalse($path);
|
||||
}
|
||||
|
||||
public function testFindAllLegacyAliasFiles()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/legacy');
|
||||
|
||||
$result = $this->sut->findAllLegacyAliasFiles();
|
||||
$paths = $this->simplifyToBasenamesWithLocation($result);
|
||||
$this->assertEquals('legacy/aliases.drushrc.php,legacy/cc.aliases.drushrc.php,legacy/one.alias.drushrc.php,legacy/pantheon.aliases.drushrc.php,legacy/server.aliases.drushrc.php', implode(',', $paths));
|
||||
}
|
||||
|
||||
protected function assertLocation($expected, $path)
|
||||
{
|
||||
$this->assertEquals($expected, basename(dirname($path)));
|
||||
}
|
||||
|
||||
protected function assertBasename($expected, $path)
|
||||
{
|
||||
$this->assertEquals($expected, basename($path));
|
||||
}
|
||||
|
||||
protected function simplifyToBasenamesWithLocation($result)
|
||||
{
|
||||
if (!is_array($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = array_map(
|
||||
function ($item) {
|
||||
return basename(dirname($item)) . '/' . basename($item);
|
||||
}
|
||||
,
|
||||
$result
|
||||
);
|
||||
|
||||
sort($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
165
vendor/consolidation/site-alias/tests/SiteAliasFileLoaderTest.php
vendored
Normal file
165
vendor/consolidation/site-alias/tests/SiteAliasFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
|
||||
|
||||
class SiteAliasFileLoaderTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
use FunctionUtils;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
$this->sut = new SiteAliasFileLoader();
|
||||
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->sut->addLoader('yml', $ymlLoader);
|
||||
}
|
||||
|
||||
public function testLoadWildAliasFile()
|
||||
{
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/wild.site.yml'));
|
||||
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Try to get the dev environment.
|
||||
$name = SiteAliasName::parse('@wild.dev');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/wild', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Try to fetch an environment that does not exist. Since this is
|
||||
// a wildcard alias, there should
|
||||
$name = SiteAliasName::parse('@wild.other');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/wild/path/to/wild', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
}
|
||||
|
||||
public function testLoadSingleAliasFile()
|
||||
{
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/simple.site.yml'));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/single.site.yml'));
|
||||
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Add a secondary location
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/other';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Look for a simple alias with no environments defined
|
||||
$name = new SiteAliasName('simple');
|
||||
$this->assertEquals('simple', $name->sitename());
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/simple', $result->get('root'));
|
||||
|
||||
// Look for a single alias without an environment specified.
|
||||
$name = new SiteAliasName('single');
|
||||
$this->assertEquals('single', $name->sitename());
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with environment explicitly requested.
|
||||
$name = SiteAliasName::parse('@single.alternate');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/alternate/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with location explicitly filtered.
|
||||
$name = SiteAliasName::parse('@other.single.dev');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/other/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('baz', $result->get('foo'));
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = SiteAliasName::parse('@missing');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertFalse($result);
|
||||
|
||||
// Try to fetch an alias using a missing location
|
||||
$name = SiteAliasName::parse('@missing.single.alternate');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testLoadLegacy()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/legacy');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
// Look for a simple alias with no environments defined
|
||||
$name = new SiteAliasName('simple');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/simple', $result->get('root'));
|
||||
|
||||
// Look for a single alias without an environment specified.
|
||||
$name = new SiteAliasName('single');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with environment explicitly requested.
|
||||
$name = new SiteAliasName('single', 'alternate');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/alternate/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = new SiteAliasName('missing');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertFalse($result);
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = new SiteAliasName('missing');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testLoadAll()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$all = $this->sut->loadAll();
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', array_keys($all)));
|
||||
}
|
||||
|
||||
public function testLoadMultiple()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$aliases = $this->sut->loadMultiple('single');
|
||||
$this->assertEquals('@single.dev,@single.alternate,@single.empty,@other.single.dev,@other.single.other', implode(',', array_keys($aliases)));
|
||||
}
|
||||
|
||||
public function testLoadLocation()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$aliases = $this->sut->loadLocation('other');
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', array_keys($aliases)));
|
||||
}
|
||||
}
|
215
vendor/consolidation/site-alias/tests/SiteAliasManagerTest.php
vendored
Normal file
215
vendor/consolidation/site-alias/tests/SiteAliasManagerTest.php
vendored
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class SiteAliasManagerTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
|
||||
protected $manager;
|
||||
|
||||
/**
|
||||
* Set up for tests
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$root = $this->siteDir();
|
||||
$referenceData = [];
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
|
||||
$aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$aliasLoader->addLoader('yml', $ymlLoader);
|
||||
|
||||
$this->manager = new SiteAliasManager($aliasLoader, $root);
|
||||
$this->manager
|
||||
->setReferenceData($referenceData)
|
||||
->addSearchLocation($siteAliasFixtures);
|
||||
}
|
||||
|
||||
public function managerGetTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function managerGetWithOtherLocationTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.other', 'foo: baz
|
||||
root: /other/other/path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function managerGetWithDupLocationsTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.dev', 'foo: baz
|
||||
root: /other/path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@dup.single.dev', 'foo: dup
|
||||
root: /dup/path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This test is just to ensure that our fixture data is being loaded
|
||||
* accurately so that we can start writing tests. Its okay to remove
|
||||
* rather than maintain this test once the suite is mature.
|
||||
*/
|
||||
public function testGetMultiple()
|
||||
{
|
||||
// First set of tests: get all aliases in the default location
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@single.alternate,@single.dev,@single.empty', implode(',', $allNames));
|
||||
|
||||
// Next set of tests: Get all aliases in the 'other' location
|
||||
|
||||
$this->addAlternateLocation('other');
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
|
||||
// Add the 'dup' location and do some more tests
|
||||
|
||||
$this->addAlternateLocation('dup');
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.bob.dev,@dup.bob.other,@dup.fred.dev,@dup.fred.other,@dup.single.alternate,@dup.single.dev,@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@dup');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.bob.dev,@dup.bob.other,@dup.fred.dev,@dup.fred.other,@dup.single.alternate,@dup.single.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@dup.single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.single.alternate,@dup.single.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other.single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetTestValues
|
||||
*/
|
||||
public function testGet(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$alias = $this->manager->get($aliasName);
|
||||
$actual = $this->renderAlias($alias);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetWithOtherLocationTestValues
|
||||
*/
|
||||
public function testGetWithOtherLocation(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$this->addAlternateLocation('other');
|
||||
$this->testGet($aliasName, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetWithDupLocationsTestValues
|
||||
*/
|
||||
public function testGetWithDupLocations(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$this->addAlternateLocation('dup');
|
||||
$this->testGetWithOtherLocation($aliasName, $expected);
|
||||
}
|
||||
|
||||
protected function addAlternateLocation($fixtureDirName)
|
||||
{
|
||||
// Add another search location IN ADDITION to the one
|
||||
// already added in the setup() mehtod.
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/' . $fixtureDirName;
|
||||
$this->manager->addSearchLocation($siteAliasFixtures);
|
||||
}
|
||||
|
||||
protected function renderAlias($alias)
|
||||
{
|
||||
if (!$alias) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return trim(Yaml::Dump($alias->export()));
|
||||
}
|
||||
}
|
49
vendor/consolidation/site-alias/tests/SiteAliasNameTest.php
vendored
Normal file
49
vendor/consolidation/site-alias/tests/SiteAliasNameTest.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteAliasNameTest extends TestCase
|
||||
{
|
||||
public function testSiteAliasName()
|
||||
{
|
||||
// Test an ambiguous sitename or env alias.
|
||||
$name = SiteAliasName::parse('@simple');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertTrue(!$name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('simple', $name->env());
|
||||
$this->assertEquals('@self.simple', (string)$name);
|
||||
|
||||
// Test a non-ambiguous sitename.env alias.
|
||||
$name = SiteAliasName::parse('@site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertTrue($name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('site', $name->sitename());
|
||||
$this->assertEquals('env', $name->env());
|
||||
$this->assertEquals('@site.env', (string)$name);
|
||||
|
||||
// Test a non-ambiguous location.sitename.env alias.
|
||||
$name = SiteAliasName::parse('@location.site.env');
|
||||
$this->assertTrue($name->hasLocation());
|
||||
$this->assertTrue($name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('location', $name->location());
|
||||
$this->assertEquals('site', $name->sitename());
|
||||
$this->assertEquals('env', $name->env());
|
||||
$this->assertEquals('@location.site.env', (string)$name);
|
||||
|
||||
// Test an invalid alias - bad character
|
||||
$name = SiteAliasName::parse('!site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertFalse($name->hasSitename());
|
||||
$this->assertFalse($name->hasEnv());
|
||||
|
||||
// Test an invalid alias - too many separators
|
||||
$name = SiteAliasName::parse('@location.group.site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertFalse($name->hasSitename());
|
||||
$this->assertFalse($name->hasEnv());
|
||||
}
|
||||
}
|
177
vendor/consolidation/site-alias/tests/SiteSpecParserTest.php
vendored
Normal file
177
vendor/consolidation/site-alias/tests/SiteSpecParserTest.php
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteSpecParserTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
|
||||
/**
|
||||
* @dataProvider parserTestValues
|
||||
*/
|
||||
public function testSiteSpecParser(
|
||||
$spec,
|
||||
$expected)
|
||||
{
|
||||
$root = $this->siteDir();
|
||||
$fixtureSite = '/' . basename($root);
|
||||
$parser = new SiteSpecParser();
|
||||
|
||||
// If the test spec begins with '/fixtures', substitute the
|
||||
// actual path to our fixture site.
|
||||
$spec = preg_replace('%^/fixtures%', $root, $spec);
|
||||
|
||||
// Make sure that our spec is valid
|
||||
$this->assertTrue($parser->validSiteSpec($spec));
|
||||
|
||||
// Parse it!
|
||||
$result = $parser->parse($spec, $root);
|
||||
|
||||
// If the result contains the path to our fixtures site, replace
|
||||
// it with the simple string '/fixtures'.
|
||||
if (isset($result['root'])) {
|
||||
$result['root'] = preg_replace("%.*$fixtureSite%", '/fixtures', $result['root']);
|
||||
}
|
||||
|
||||
// Compare the altered result with the expected value.
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validSiteSpecs
|
||||
*/
|
||||
public function testValidSiteSpecs($spec)
|
||||
{
|
||||
$this->isSpecValid($spec, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidSiteSpecs
|
||||
*/
|
||||
public function testInvalidSiteSpecs($spec)
|
||||
{
|
||||
$this->isSpecValid($spec, false);
|
||||
}
|
||||
|
||||
protected function isSpecValid($spec, $expected)
|
||||
{
|
||||
$parser = new SiteSpecParser();
|
||||
|
||||
$result = $parser->validSiteSpec($spec);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public static function validSiteSpecs()
|
||||
{
|
||||
return [
|
||||
[ '/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal#uri' ],
|
||||
[ 'user.name@example.com/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal' ],
|
||||
[ 'user@example.com/path/to/drupal' ],
|
||||
[ 'user@server#uri' ],
|
||||
[ 'user@example.com#uri' ],
|
||||
[ '#uri' ],
|
||||
];
|
||||
}
|
||||
|
||||
public static function invalidSiteSpecs()
|
||||
{
|
||||
return [
|
||||
[ 'uri' ],
|
||||
[ '@/#' ],
|
||||
[ 'user@#uri' ],
|
||||
[ '@server/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal#' ],
|
||||
[ 'user@server/path/to/drupal#uri!' ],
|
||||
[ 'user@server/path/to/drupal##uri' ],
|
||||
[ 'user#server/path/to/drupal#uri' ],
|
||||
];
|
||||
}
|
||||
|
||||
public static function parserTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'user@server/path#somemultisite',
|
||||
[
|
||||
'user' => 'user',
|
||||
'host' => 'server',
|
||||
'root' => '/path',
|
||||
'uri' => 'somemultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user.name@example.com/path#somemultisite',
|
||||
[
|
||||
'user' => 'user.name',
|
||||
'host' => 'example.com',
|
||||
'root' => '/path',
|
||||
'uri' => 'somemultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user@server/path',
|
||||
[
|
||||
'user' => 'user',
|
||||
'host' => 'server',
|
||||
'root' => '/path',
|
||||
'uri' => 'default',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user.name@example.com/path',
|
||||
[
|
||||
'user' => 'user.name',
|
||||
'host' => 'example.com',
|
||||
'root' => '/path',
|
||||
'uri' => 'default',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/fixtures#mymultisite',
|
||||
[
|
||||
'root' => '/fixtures',
|
||||
'uri' => 'mymultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'#mymultisite',
|
||||
[
|
||||
'root' => '/fixtures',
|
||||
'uri' => 'mymultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/fixtures#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/path#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/path#mymultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/bob.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/bob.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/bob
|
||||
other:
|
||||
root: /other/other/path/to/bob
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/fred.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/fred.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/fred
|
||||
other:
|
||||
root: /other/other/path/to/fred
|
8
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/single.site.yml
vendored
Normal file
8
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/single.site.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /dup/path/to/single
|
||||
alternate:
|
||||
root: /dup/alternate/path/to/single
|
||||
common:
|
||||
foo: dup
|
||||
|
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/aliases.drushrc.php
vendored
Normal file
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
$aliases['production'] = [
|
||||
'uri' => 'example.com',
|
||||
'root' => '/path/to/drupal',
|
||||
];
|
||||
|
||||
$aliases['staging'] = [
|
||||
'uri' => 'staging.example.com',
|
||||
'root' => '/path/to/drupal',
|
||||
];
|
43
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php
vendored
Normal file
43
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
$aliases['live'] = array (
|
||||
'parent' => '@server.digital-ocean',
|
||||
'project-type' => 'live',
|
||||
'root' => '/srv/www/couturecostume.com/htdocs',
|
||||
'uri' => 'couturecostume.com',
|
||||
'path-aliases' => array(
|
||||
'%dump-dir' => '/var/sql-dump/',
|
||||
),
|
||||
'target-command-specific' => array(
|
||||
'sql-sync' => array(
|
||||
'disable' => array('stage_file_proxy'),
|
||||
'permission' => array(
|
||||
'authenticated user' => array(
|
||||
'remove' => array('access environment indicator'),
|
||||
),
|
||||
'anonymous user' => array(
|
||||
'remove' => 'access environment indicator',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$aliases['update'] = array (
|
||||
'parent' => '@server.nitrogen',
|
||||
'root' => '/srv/www/update.couturecostume.com/htdocs',
|
||||
'uri' => 'update.couturecostume.com',
|
||||
'target-command-specific' => array(
|
||||
'sql-sync' => array(
|
||||
'enable' => array('environment_indicator', 'stage_file_proxy'),
|
||||
'permission' => array(
|
||||
'authenticated user' => array(
|
||||
'add' => array('access environment indicator'),
|
||||
),
|
||||
'anonymous user' => array(
|
||||
'add' => 'access environment indicator',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
3
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/do-not-find-me.php
vendored
Normal file
3
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/do-not-find-me.php
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
// The search scripts shouldn't find me as I do not match the patterns.
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/one.alias.drushrc.php
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/one.alias.drushrc.php
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
$options['uri'] = 'http://example.com';
|
||||
$options['root'] = '/path/to/drupal';
|
50
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php
vendored
Normal file
50
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Pantheon drush alias file, to be placed in your ~/.drush directory or the aliases
|
||||
* directory of your local Drush home. Once it's in place, clear drush cache:
|
||||
*
|
||||
* drush cc drush
|
||||
*
|
||||
* To see all your available aliases:
|
||||
*
|
||||
* drush sa
|
||||
*
|
||||
* See http://helpdesk.getpantheon.com/customer/portal/articles/411388 for details.
|
||||
*/
|
||||
|
||||
$aliases['outlandish-josh.test'] = array(
|
||||
'uri' => 'test-outlandish-josh.pantheonsite.io',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.test.site-id.drush.in:11621/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.test.site-id.drush.in',
|
||||
'remote-user' => 'test.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
||||
$aliases['outlandish-josh.live'] = array(
|
||||
'uri' => 'www.outlandishjosh.com',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.live.site-id.drush.in:10516/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.live.site-id.drush.in',
|
||||
'remote-user' => 'live.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
||||
$aliases['outlandish-josh.dev'] = array(
|
||||
'uri' => 'dev-outlandish-josh.pantheonsite.io',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.dev.site-id.drush.in:21086/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.dev.site-id.drush.in',
|
||||
'remote-user' => 'dev.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php
vendored
Normal file
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
$aliases['isp'] = array (
|
||||
'remote-host' => 'hydrogen.server.org',
|
||||
'remote-user' => 'www-admin',
|
||||
);
|
||||
|
||||
$aliases['nitrogen'] = array (
|
||||
'remote-host' => 'nitrogen.server.org',
|
||||
'remote-user' => 'admin',
|
||||
);
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/bob.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/bob.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/bob
|
||||
other:
|
||||
root: /other/other/path/to/bob
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/fred.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/fred.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/fred
|
||||
other:
|
||||
root: /other/other/path/to/fred
|
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/simple.site.yml
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/simple.site.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
root: /other/path/to/simple
|
7
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/single.site.yml
vendored
Normal file
7
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/single.site.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /other/path/to/single
|
||||
other:
|
||||
root: /other/other/path/to/single
|
||||
common:
|
||||
foo: baz
|
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/simple.site.yml
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/simple.site.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
root: /path/to/simple
|
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/single.site.yml
vendored
Normal file
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/single.site.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /path/to/single
|
||||
alternate:
|
||||
root: /alternate/path/to/single
|
||||
empty:
|
||||
foo: bar
|
||||
common:
|
||||
foo: bar
|
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/wild.site.yml
vendored
Normal file
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/wild.site.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /path/to/wild
|
||||
uri: https://dev.example.com
|
||||
'*':
|
||||
root: /wild/path/to/wild
|
||||
uri: https://${env-name}.example.com
|
||||
common:
|
||||
foo: bar
|
1
vendor/consolidation/site-alias/tests/fixtures/sites/d8/sites/mymultisite/settings.php
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sites/d8/sites/mymultisite/settings.php
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<?php
|
24
vendor/consolidation/site-alias/tests/src/FixtureFactory.php
vendored
Normal file
24
vendor/consolidation/site-alias/tests/src/FixtureFactory.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use \Drush\Config\Environment;
|
||||
|
||||
trait FixtureFactory
|
||||
{
|
||||
protected function fixturesDir()
|
||||
{
|
||||
return dirname(__DIR__) . '/fixtures';
|
||||
}
|
||||
|
||||
protected function homeDir()
|
||||
{
|
||||
return $this->fixturesDir() . '/home';
|
||||
}
|
||||
|
||||
// It is still an aspirational goal to add Drupal 7 support back to Drush. :P
|
||||
// For now, only Drupal 8 is supported.
|
||||
protected function siteDir($majorVersion = '8')
|
||||
{
|
||||
return $this->fixturesDir() . '/sites/d' . $majorVersion;
|
||||
}
|
||||
}
|
14
vendor/consolidation/site-alias/tests/src/FunctionUtils.php
vendored
Normal file
14
vendor/consolidation/site-alias/tests/src/FunctionUtils.php
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
trait FunctionUtils
|
||||
{
|
||||
protected $sut;
|
||||
|
||||
protected function callProtected($methodName, $args = [])
|
||||
{
|
||||
$r = new \ReflectionMethod($this->sut, $methodName);
|
||||
$r->setAccessible(true);
|
||||
return $r->invokeArgs($this->sut, $args);
|
||||
}
|
||||
}
|
Reference in a new issue