X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fisolation%2Ftests%2FSiteAliasFileDiscoveryTest.php;fp=vendor%2Fdrush%2Fdrush%2Fisolation%2Ftests%2FSiteAliasFileDiscoveryTest.php;h=5cf85c469d3285de68db5ee182613da55ad2be5e;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/drush/drush/isolation/tests/SiteAliasFileDiscoveryTest.php b/vendor/drush/drush/isolation/tests/SiteAliasFileDiscoveryTest.php new file mode 100644 index 000000000..5cf85c469 --- /dev/null +++ b/vendor/drush/drush/isolation/tests/SiteAliasFileDiscoveryTest.php @@ -0,0 +1,70 @@ +sut = new SiteAliasFileDiscovery(); + } + + public function testSearchForSingleAliasFile() + { + $this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/single'); + + $path = $this->sut->findSingleSiteAliasFile('single'); + $this->assertLocation('single', $path); + $this->assertBasename('single.site.yml', $path); + } + + public function testSearchForMissingSingleAliasFile() + { + $this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/single'); + + $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/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; + } +}