From bc76e0014b59337d7b3f6b31e17daee3f4781797 Mon Sep 17 00:00:00 2001 From: Danack Date: Thu, 20 Feb 2014 17:30:51 +0000 Subject: [PATCH] Moved tests that are expected to work into their own directory. Added test for composer.json in incorrect directory. --- .../Repository/ArtifactRepositoryTest.php | 49 +++++++++++++++++- .../{ => correct}/composer-1.0.0-alpha6.zip | Bin .../{ => correct}/not-an-artifact.zip | Bin .../artifacts/{ => correct}/package0.zip | Bin .../artifacts/{ => correct}/package2.zip | Bin .../subfolder/not-an-artifact.zip | Bin .../{ => correct}/subfolder/package1.zip | Bin 7 files changed, 48 insertions(+), 1 deletion(-) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/composer-1.0.0-alpha6.zip (100%) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/not-an-artifact.zip (100%) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/package0.zip (100%) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/package2.zip (100%) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/subfolder/not-an-artifact.zip (100%) rename tests/Composer/Test/Repository/Fixtures/artifacts/{ => correct}/subfolder/package1.zip (100%) diff --git a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php index 5ffae515a..f83ceee8c 100644 --- a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php @@ -26,9 +26,11 @@ class ArtifactRepositoryTest extends TestCase 'composer/composer-1.0.0-alpha6', 'vendor1/package2-4.3.2', 'vendor3/package1-5.4.3', + 'test/jsonInRoot-1.0.0', + 'test/jsonInFirstLevel-1.0.0' ); - $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts'); + $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts/correct'); $repo = new ArtifactRepository($coordinates, new NullIO(), new Config()); $foundPackages = array_map(function(BasePackage $package) { @@ -40,4 +42,49 @@ class ArtifactRepositoryTest extends TestCase $this->assertSame($expectedPackages, $foundPackages); } + + public function testExtractConfigFails() + { + $this->setExpectedException('RuntimeException', "Shouldn't have picked up composer.json from a location other than root or first level directory."); + + $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts/error/jsonWrongDirectory'); + new ArtifactRepository($coordinates, new NullIO(), new Config()); + } } + +//$archivesToCreate = array( +// 'jsonInRoot' => array( +// "extra.txt" => "Testing testing testing", +// "composer.json" => '{ "name": "test/jsonInRoot", "version": "1.0.0" }', +// "subdir/extra.txt" => "Testing testing testing", +// "subdir/extra2.txt" => "Testing testing testing", +// ), +// +// 'jsonInFirstLevel' => array( +// "extra.txt" => "Testing testing testing", +// "subdir/composer.json" => '{ "name": "test/jsonInFirstLevel", "version": "1.0.0" }', +// "subdir/extra.txt" => "Testing testing testing", +// "subdir/extra2.txt" => "Testing testing testing", +// ), +// +// 'jsonInSecondLevel' => array( +// "extra.txt" => "Testing testing testing", +// "subdir/extra1.txt" => "Testing testing testing", +// "subdir/foo/composer.json" => '{ "name": "test/jsonInSecondLevel", "version": "1.0.0" }', +// "subdir/foo/extra1.txt" => "Testing testing testing", +// "subdir/extra2.txt" => "Testing testing testing", +// "subdir/extra3.txt" => "Testing testing testing", +// ), +//); +// +//foreach($archivesToCreate as $archiveName => $fileDetails) { +// $zipFile = new ZipArchive(); +// $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE); +// +// foreach ($fileDetails as $filename => $fileContents) { +// $zipFile->addFromString($filename, $fileContents); +// } +// +// $zipFile->close(); +//} + diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/composer-1.0.0-alpha6.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/composer-1.0.0-alpha6.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/composer-1.0.0-alpha6.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/composer-1.0.0-alpha6.zip diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/not-an-artifact.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/not-an-artifact.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/not-an-artifact.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/not-an-artifact.zip diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/package0.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/package0.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/package0.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/package0.zip diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/package2.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/package2.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/package2.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/package2.zip diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/not-an-artifact.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/subfolder/not-an-artifact.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/not-an-artifact.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/subfolder/not-an-artifact.zip diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/package1.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/correct/subfolder/package1.zip similarity index 100% rename from tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/package1.zip rename to tests/Composer/Test/Repository/Fixtures/artifacts/correct/subfolder/package1.zip