Esempio n. 1
0
 /**
  * @param array $tag
  * @param string $current_version
  * @param int $result
  *
  * @return UpdateCommand
  */
 protected function getCommandToExecute(array $tag, $current_version, $result)
 {
     $that = $this;
     $installer = $this->getMockBuilder('\\Composer\\Installer')->disableOriginalConstructor()->getMock();
     $installer->expects($this->once())->method('run')->will($this->returnValue($result));
     $this->container->expects($that->at(0))->method('get')->will($this->returnValue($this->composer))->with('anime_db.composer');
     $this->container->expects($that->at(1))->method('get')->will($this->returnValue($this->github))->with('anime_db.client.github');
     $this->composer->expects($this->once())->method('setIO')->will($this->returnCallback(function ($io) use($that) {
         $that->assertInstanceOf('\\Composer\\IO\\ConsoleIO', $io);
     }));
     $this->github->expects($this->once())->method('getLastRelease')->will($this->returnValue($tag))->with('anime-db/anime-db');
     $this->composer->expects($this->atLeastOnce())->method('getRootPackage')->will($this->returnValue($this->package));
     $this->composer->expects($this->once())->method('getInstaller')->will($this->returnValue($installer));
     $this->package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue($current_version));
     /* @var $helper_set HelperSet */
     $helper_set = $this->getMockBuilder('\\Symfony\\Component\\Console\\Helper\\HelperSet')->disableOriginalConstructor()->getMock();
     $this->output->expects($this->at(0))->method('writeln')->with('Search for a new version of the application');
     $command = new UpdateCommand();
     $command->setHelperSet($helper_set);
     $command->setContainer($this->container);
     return $command;
 }