From 566f2c48ada6ecede3d50c35e2226397aaadef6d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 3 Apr 2020 10:47:40 +0700 Subject: [PATCH] test Autoloader::initialize() with composer path not found --- tests/system/Autoloader/AutoloaderTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index c2a932964e0e..90976ea1421c 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -232,4 +232,22 @@ public function testFindsComposerRoutes() $namespaces = $this->loader->getNamespace(); $this->assertArrayHasKey('Laminas\\Escaper', $namespaces); } + + public function testFindsComposerRoutesWithComposerPathNotFound() + { + $composerPath = COMPOSER_PATH; + + $config = new Autoload(); + $moduleConfig = new Modules(); + $moduleConfig->discoverInComposer = true; + + $this->loader = new Autoloader(); + + rename(COMPOSER_PATH, COMPOSER_PATH . '.backup'); + $this->loader->initialize($config, $moduleConfig); + rename(COMPOSER_PATH . '.backup', $composerPath); + + $namespaces = $this->loader->getNamespace(); + $this->assertArrayNotHasKey('Laminas\\Escaper', $namespaces); + } }