/** * @test */ public function shouldReturnFalseIfPushFails() { $package = new LocalPackage(array(), '/tmp', new Package()); $gitWorkingCopy = $this->getMockBuilder('GitWrapper\\GitWorkingCopy')->disableOriginalConstructor()->getMock(); $gitWorkingCopy->expects($this->once())->method('add')->with($this->equalTo('.'))->will($this->returnValue($gitWorkingCopy)); $gitWorkingCopy->expects($this->once())->method('commit')->with($this->equalTo('CS Fixes'))->will($this->returnValue($gitWorkingCopy)); $gitWorkingCopy->expects($this->once())->method('push')->with($this->equalTo('origin'), $this->equalTo('cs_fixer')); $gitWorkingCopy->expects($this->once())->method('getStatus')->will($this->returnValue('something')); $command = new CommitAndPush($this->mockEventDispatcher()); $this->assertFalse($command->execute($gitWorkingCopy, $package)); }
public function execute(Package $package, $dryRun = false) { $client = $this->getAuthenticateGitHubClient(); $gitWrapper = $this->getGitWrapper(); $step = new Step\ForkPackage($client, $this->dispatcher); $repository = $step->execute($package); sleep(180); $localPackage = new LocalPackage($repository, $this->sanitizeLocallyDir($package), $package); $step = new Step\CloneLocally($gitWrapper, $this->dispatcher); $step->execute($localPackage); $step = new Step\ExecuteCSFixer($this->phpCsFixerBin, 4000, $this->dispatcher); $step->execute($localPackage); if (!$dryRun) { $step = new Step\CommitAndPush($this->dispatcher); $git = $this->getGitWorking($gitWrapper, $localPackage); $step->execute($git, $localPackage); $step = new Step\MakeAPR($client, new FunnyMessageRepository(), $this->dispatcher); $step->execute($localPackage); } return $localPackage; }