protected function mockComposerObjects($packageExtraValue = null) { $this->composerMock = $this->getMock('Composer\\Composer', array('getPackage')); $this->packageMock = $this->getMockForAbstractClass('Composer\\Package\\PackageInterface'); $this->packageMock->expects($this->any())->method('getExtra')->will($this->returnValue($packageExtraValue)); $this->composerMock->expects($this->any())->method('getPackage')->will($this->returnValue($this->packageMock)); $this->composerEventMock = $this->getMock('Composer\\Script\\Event', array('getComposer'), array('postPackageUpdate', $this->composerMock, $this->getMockForAbstractClass('Composer\\IO\\IOInterface'), true)); $this->composerEventMock->expects($this->any())->method('getComposer')->will($this->returnValue($this->composerMock)); }
/** * @param array $localConfig * @return \Composer\Composer */ public function createComposer(array $localConfig) { $io = new \Composer\IO\NullIO(); $composer = new \Composer\Composer(); $composerConfig = new \Composer\Config(); $composerConfig->merge(array('config' => array('home' => CM_Bootloader::getInstance()->getDirTmp() . 'composer/'))); $composerConfig->merge($localConfig); $composer->setConfig($composerConfig); $im = $this->createInstallationManager(); $composer->setInstallationManager($im); $this->createDefaultInstallers($im, $composer, $io); $dispatcher = new \Composer\EventDispatcher\EventDispatcher($composer, $io); $composer->setEventDispatcher($dispatcher); $generator = new \Composer\Autoload\AutoloadGenerator($dispatcher); $composer->setAutoloadGenerator($generator); $rm = $this->createRepositoryManager($composer, $io); $composer->setRepositoryManager($rm); $loader = new \Composer\Package\Loader\RootPackageLoader($rm, $composerConfig); $package = $loader->load($localConfig); $composer->setPackage($package); return $composer; }
/** * Creates a composer instance for testing. * * @return \Composer\Composer */ protected function createComposer() { $config = new \Composer\Config(); $config->merge(array('config' => array('vendor-dir' => dirname(__FILE__) . '/_files/vendor', 'bin-dir' => dirname(__FILE__) . '/_files/bin'))); $composer = new \Composer\Composer(); $composer->setConfig($config); $composer->setPackage($this->createRootPackage()); return $composer; }