X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal-composer%2Fdrupal-scaffold%2Ftests%2FFetcherTest.php;fp=vendor%2Fdrupal-composer%2Fdrupal-scaffold%2Ftests%2FFetcherTest.php;h=39b3e730c441ab2ae04dc198c6cd45452685a077;hp=0000000000000000000000000000000000000000;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/drupal-composer/drupal-scaffold/tests/FetcherTest.php b/vendor/drupal-composer/drupal-scaffold/tests/FetcherTest.php new file mode 100644 index 000000000..39b3e730c --- /dev/null +++ b/vendor/drupal-composer/drupal-scaffold/tests/FetcherTest.php @@ -0,0 +1,99 @@ +rootDir = realpath(realpath(__DIR__ . '/..')); + + // Prepare temp directory. + $this->fs = new Filesystem(); + $this->tmpDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'drupal-scaffold'; + $this->ensureDirectoryExistsAndClear($this->tmpDir); + + chdir($this->tmpDir); + } + + /** + * Makes sure the given directory exists and has no content. + * + * @param string $directory + */ + protected function ensureDirectoryExistsAndClear($directory) { + if (is_dir($directory)) { + $this->fs->removeDirectory($directory); + } + mkdir($directory, 0777, true); + } + + public function testFetch() { + $fetcher = new FileFetcher(new RemoteFilesystem(new NullIO()), 'http://cgit.drupalcode.org/drupal/plain/{path}?h={version}', ['.htaccess', 'sites/default/default.settings.php']); + $fetcher->fetch('8.1.1', $this->tmpDir); + $this->assertFileExists($this->tmpDir . '/.htaccess'); + $this->assertFileExists($this->tmpDir . '/sites/default/default.settings.php'); + } + + /** + * Tests version specific files. + */ + public function testFetchVersionSpecific() { + $fetcher = new FileFetcher(new RemoteFilesystem(new NullIO()), 'http://cgit.drupalcode.org/drupal/plain/{path}?h={version}', ['.eslintrc', '.eslintrc.json']); + + $this->setExpectedException(TransportException::class); + $fetcher->fetch('8.2.x', $this->tmpDir); + + $this->assertFileExists($this->tmpDir . '/.eslintrc'); + $this->assertFileNotExists($this->tmpDir . '/.eslintrc.json'); + + // Remove downloaded files to retest with 8.3.x. + @unlink($this->tmpDir . '/.eslintrc'); + + $this->setExpectedException(TransportException::class); + $fetcher->fetch('8.3.x', $this->tmpDir); + + $this->assertFileExists($this->tmpDir . '/.eslintrc.json'); + $this->assertFileNotExists($this->tmpDir . '/.eslintrc'); + } + + public function testInitialFetch() { + $fetcher = new InitialFileFetcher(new RemoteFilesystem(new NullIO()), 'http://cgit.drupalcode.org/drupal/plain/{path}?h={version}', ['sites/default/default.settings.php' => 'sites/default/settings.php']); + $fetcher->fetch('8.1.1', $this->tmpDir); + $this->assertFileExists($this->tmpDir . '/sites/default/settings.php'); + } +}