/** * @dataProvider shouldCreateComposerLockBadgeProvider */ public function testShouldCreateComposerLockBadge($returnCode, $expected) { $package = $this->getMockWithoutInvokingTheOriginalConstructor('\\PUGX\\Badge\\Model\\Package'); $package->expects($this->once())->method('hasStableVersion')->will($this->returnValue(true)); $package->expects($this->once())->method('getLatestStableVersion')->will($this->returnValue('v2.0')); $this->repository->expects($this->any())->method('fetchByRepository')->will($this->returnValue($package)); $repo = $this->getMockWithoutInvokingTheOriginalConstructor('\\Packagist\\Api\\Result\\Package'); $repo->expects($this->once())->method('getRepository')->will($this->returnValue('RepoURI')); $package->expects($this->once())->method('getOriginalObject')->will($this->returnValue($repo)); $response = $this->getMockWithoutInvokingTheOriginalConstructor('\\Guzzle\\Http\\Message\\Response'); $response->expects($this->once())->method('getStatusCode')->will($this->returnValue($returnCode)); $request = $this->getMockWithoutInvokingTheOriginalConstructor('\\Guzzle\\Http\\Message\\RequestInterface'); $this->client->expects($this->once())->method('head')->will($this->returnValue($request)); $this->client->expects($this->once())->method('send')->will($this->returnValue($response)); $repository = 'PUGX/badge-poser'; $badge = $this->useCase->createComposerLockBadge($repository); $this->assertEquals($expected, $badge->getStatus()); }
protected function fetchPackage($repository) { return $this->packageRepository->fetchByRepository($repository); }