public function testDownload() { /* @var $package \PHPUnit_Framework_MockObject_MockObject|RootPackageInterface */ $package = $this->getMock('\\Composer\\Package\\RootPackageInterface'); $manager = $this->getMockBuilder('\\Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); $manager->expects($this->once())->method('getDownloaderForInstalledPackage')->will($this->returnSelf())->with($package); $manager->expects($this->once())->method('download')->with($package, $this->root_dir); if (defined('PHP_WINDOWS_VERSION_BUILD')) { $manager->expects($this->once())->method('setOutputProgress')->will($this->returnSelf())->with(false); } $composer = $this->getComposer(); $composer->expects($this->once())->method('getDownloadManager')->will($this->returnValue($manager)); $this->composer->download($package, $this->root_dir); }
/** * @param array $tag * @param Composer $composer * @param OutputInterface $output */ protected function doUpdateItself(array $tag, Composer $composer, OutputInterface $output) { $output->writeln('Discovered a new version of the application: <info>' . $tag['name'] . '</info>'); // create install package $package = new Package('anime-db/anime-db', $tag['version'], $tag['name']); $package->setDistType('zip'); $package->setDistUrl($tag['zipball_url']); $package->setInstallationSource('dist'); // download new version $target = sys_get_temp_dir() . '/anime-db'; $this->getContainer()->get('filesystem')->remove($target); $composer->download($package, $target); $new_package = $composer->getPackageFromConfigFile($target . '/composer.json'); $dispatcher = $this->getContainer()->get('event_dispatcher'); // notify about downloaded $dispatcher->dispatch(StoreEvents::DOWNLOADED, new Downloaded($target, $new_package, $composer->getRootPackage())); // rewriting the application files $this->rewriting($target); // notify about updated // event will be sent after the update application components $this->getContainer()->get('anime_db.event_dispatcher')->dispatch(StoreEvents::UPDATED, new Updated($new_package)); $composer->reload(); $output->writeln('<info>Update itself has been completed</info>'); }