public function testGetModules() { $filesystemTmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp(); $dirRoot = $filesystemTmp->getAdapter()->getPathPrefix() . '/foo-app/'; $composerFile = new \Composer\Json\JsonFile($dirRoot . 'composer.json'); $composerFile->write(array('name' => 'foo/bar', 'require' => array('cargomedia/cm' => '*'), 'extra' => ['cm-modules' => ['Package' => ['path' => 'package/']]])); $filesystemTmp->ensureDirectory('foo-app/vendor/composer/'); $installedFile = new \Composer\Json\JsonFile($dirRoot . 'vendor/composer/installed.json'); $installedFile->write([['name' => 'cargomedia/cm', 'version' => '1.3.10', 'type' => 'library', 'extra' => ['cm-modules' => ['CM' => ['path' => '']]], 'autoload' => ['psr-0' => ['CM_' => 'library/']]]]); $installation = new CM_App_Installation($dirRoot); $expectedModules = [new CM_App_Module('CM', 'vendor/cargomedia/cm/'), new CM_App_Module('Package', 'package/')]; $this->assertEquals($expectedModules, $installation->getModules()); }
/** * @return CM_App_Package * @throws CM_Exception_Invalid */ private function _getRootPackage() { $rootPackageName = $this->getComposer()->getPackage()->getName(); foreach ($this->_appInstallation->getPackages() as $package) { if ($package->getName() === $rootPackageName) { return $package; } } throw new CM_Exception_Invalid('No package with rootPackageName `' . $rootPackageName . '` was found.'); }
/** * @return array */ private function _getModulePaths() { $cacheKey = CM_CacheConst::Modules; $apcCache = new CM_Cache_Storage_Apc(); if (false === ($modulePaths = $apcCache->get($cacheKey))) { $fileCache = new CM_Cache_Storage_File(); $installation = new CM_App_Installation(DIR_ROOT); if ($installation->getUpdateStamp() > $fileCache->getCreateStamp($cacheKey) || false === ($modulePaths = $fileCache->get($cacheKey))) { $modulePaths = $installation->getModulePaths(); $fileCache->set($cacheKey, $modulePaths); } $apcCache->set($cacheKey, $modulePaths); } return $modulePaths; }