From 8df263a75645238e7f7d9c277fe485c7cf6daf93 Mon Sep 17 00:00:00 2001 From: remorhaz Date: Mon, 24 Feb 2020 14:43:00 +0200 Subject: [PATCH] Test added for issue #8622 fix --- .../Test/Autoload/AutoloadGeneratorTest.php | 52 +++++++++++++++++++ .../Autoload/Fixtures/autoload_classmap9.php | 12 +++++ 2 files changed, 64 insertions(+) create mode 100644 tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 055b03e1c..3cd8f7ff2 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -486,6 +486,58 @@ class AutoloadGeneratorTest extends TestCase $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); } + public function testNonDevAutoloadReplacesNestedRequirements() + { + $package = new Package('a', '1.0', '1.0'); + $package->setRequires(array( + new Link('a', 'a/a') + )); + + $packages = array(); + $packages[] = $a = new Package('a/a', '1.0', '1.0'); + $packages[] = $b = new Package('b/b', '1.0', '1.0'); + $packages[] = $c = new Package('c/c', '1.0', '1.0'); + $packages[] = $d = new Package('d/d', '1.0', '1.0'); + $packages[] = $e = new Package('e/e', '1.0', '1.0'); + $a->setAutoload(array('classmap' => array('src/A.php'))); + $a->setRequires(array( + new Link('a/a', 'b/b') + )); + $b->setAutoload(array('classmap' => array('src/B.php'))); + $b->setRequires(array( + new Link('b/b', 'e/e') + )); + $c->setAutoload(array('classmap' => array('src/C.php'))); + $c->setReplaces(array( + new Link('c/c', 'b/b') + )); + $c->setRequires(array( + new Link('c/c', 'd/d') + )); + $d->setAutoload(array('classmap' => array('src/D.php'))); + $e->setAutoload(array('classmap' => array('src/E.php'))); + + $this->repository->expects($this->once()) + ->method('getCanonicalPackages') + ->will($this->returnValue($packages)); + + $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src'); + $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); + $this->fs->ensureDirectoryExists($this->vendorDir.'/c/c/src'); + $this->fs->ensureDirectoryExists($this->vendorDir.'/d/d/src'); + $this->fs->ensureDirectoryExists($this->vendorDir.'/e/e/src'); + + file_put_contents($this->vendorDir.'/a/a/src/A.php', 'vendorDir.'/b/b/src/B.php', 'vendorDir.'/c/c/src/C.php', 'vendorDir.'/d/d/src/D.php', 'vendorDir.'/e/e/src/E.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); + + $this->assertAutoloadFiles('classmap9', $this->vendorDir.'/composer', 'classmap'); + } + public function testPharAutoload() { $package = new Package('a', '1.0', '1.0'); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php new file mode 100644 index 000000000..f9ad3ca30 --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_classmap9.php @@ -0,0 +1,12 @@ + $vendorDir . '/a/a/src/A.php', + 'C' => $vendorDir . '/c/c/src/C.php', + 'D' => $vendorDir . '/d/d/src/D.php', +);