From 9172d0a9dac915efc723a0addf757666bf6b81c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 3 Mar 2015 13:33:58 +0100 Subject: [PATCH] Enhancement: Assert indexAction() of ContributorsController can be accessed --- .../Controller/ContributorsControllerTest.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 module/Application/test/ApplicationTest/Integration/Controller/ContributorsControllerTest.php diff --git a/module/Application/test/ApplicationTest/Integration/Controller/ContributorsControllerTest.php b/module/Application/test/ApplicationTest/Integration/Controller/ContributorsControllerTest.php new file mode 100644 index 00000000..66cccffd --- /dev/null +++ b/module/Application/test/ApplicationTest/Integration/Controller/ContributorsControllerTest.php @@ -0,0 +1,83 @@ +setApplicationConfig(Bootstrap::getConfig()); + } + + public function testContributorsActionCanBeAccessed() + { + $vendor = 'foo'; + $name = 'bar'; + + $config = $this->getApplicationServiceLocator()->get('Config'); + + $config['zf-modules'] = [ + 'repository' => [ + 'owner' => $vendor, + 'name' => $name, + ], + ]; + + $repositoryRetriever = $this->getMockBuilder(Service\RepositoryRetriever::class) + ->disableOriginalConstructor() + ->getMock() + ; + + $repositoryRetriever + ->expects($this->once()) + ->method('getContributors') + ->with( + $this->equalTo($vendor), + $this->equalTo($name) + ) + ->willReturn([]) + ; + + $metaData = new stdClass(); + $metaData->forks_count = 200; + $metaData->stargazers_count = 250; + $metaData->watchers_count = 300; + + $repositoryRetriever + ->expects($this->once()) + ->method('getUserRepositoryMetadata') + ->with( + $this->equalTo($vendor), + $this->equalTo($name) + ) + ->willReturn($metaData) + ; + + $this->getApplicationServiceLocator() + ->setAllowOverride(true) + ->setService( + 'Config', + $config + ) + ->setService( + Service\RepositoryRetriever::class, + $repositoryRetriever + ) + ; + + $this->dispatch('/contributors'); + + $this->assertControllerName(Controller\ContributorsController::class); + $this->assertActionName('index'); + $this->assertResponseStatusCode(Http\Response::STATUS_CODE_200); + } +}