From 8e8375a4e9f83361a750b20b0cf37995aea839ab Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Thu, 29 Jan 2015 20:40:41 +0100 Subject: [PATCH 1/5] This fix api limit This commit resend isModule check only after submit repository --- module/ZfModule/src/ZfModule/Controller/IndexController.php | 4 ---- .../Integration/Controller/IndexControllerTest.php | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/module/ZfModule/src/ZfModule/Controller/IndexController.php b/module/ZfModule/src/ZfModule/Controller/IndexController.php index 4f64489c..9c644a2d 100644 --- a/module/ZfModule/src/ZfModule/Controller/IndexController.php +++ b/module/ZfModule/src/ZfModule/Controller/IndexController.php @@ -136,10 +136,6 @@ private function unregisteredRepositories(RepositoryCollection $repositories) return false; } - if (!$this->moduleService->isModule($repository)) { - return false; - } - if ($this->moduleMapper->findByName($repository->name)) { return false; } diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php index 37be1bca..fd05d1be 100644 --- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php +++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php @@ -179,7 +179,7 @@ public function testIndexActionRendersValidModulesOnly() $viewVariable = $viewModel->getVariable('repositories'); $this->assertInternalType('array', $viewVariable); - $this->assertCount(1, $viewVariable); + $this->assertCount(2, $viewVariable); $this->assertSame($validModule, $viewVariable[0]); } @@ -392,7 +392,7 @@ public function testOrganizationActionRendersValidModulesOnly() $viewVariable = $viewModel->getVariable('repositories'); $this->assertInternalType('array', $viewVariable); - $this->assertCount(1, $viewVariable); + $this->assertCount(2, $viewVariable); $this->assertSame($validModule, $viewVariable[0]); } From 56b23886e5e53fd5182af981b12c08bcceee87d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 24 Feb 2015 13:54:34 +0100 Subject: [PATCH 2/5] Fix: Assert that isModule() is never called --- .../Integration/Controller/IndexControllerTest.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php index fd05d1be..32f78abe 100644 --- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php +++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php @@ -120,15 +120,8 @@ public function testIndexActionRendersValidModulesOnly() ; $moduleService - ->expects($this->any()) + ->expects($this->never()) ->method('isModule') - ->willReturnCallback(function ($repository) use ($nonModule) { - if ($repository !== $nonModule) { - return true; - } - - return false; - }) ; $moduleMapper = $this->getMockBuilder(Mapper\Module::class) From 7c80ed116114744ab3f7dc859b059e684bf5a8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 24 Feb 2015 13:57:31 +0100 Subject: [PATCH 3/5] Fix: Remove non module from test arrangement --- .../Controller/IndexControllerTest.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php index 32f78abe..01455fe2 100644 --- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php +++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php @@ -84,21 +84,18 @@ public function testIndexActionFetches100MostRecentlyUpdatedUserRepositories() $this->assertResponseStatusCode(Http\Response::STATUS_CODE_200); } - public function testIndexActionRendersValidModulesOnly() + public function testIndexActionRendersUnregisteredModulesOnly() { $this->authenticatedAs(new User()); - $validModule = $this->validModule(); - - $nonModule = $this->nonModule(); + $unregisteredModule = $this->validModule(); $registeredModule = $this->registeredModule(); $repositories = [ - $validModule, - $nonModule, + $unregisteredModule, $registeredModule, - $this->forkedModule(), $this->moduleWithoutPushPermissions(), + $this->forkedModule(), ]; $repositoryCollection = $this->repositoryCollectionMock($repositories); @@ -172,8 +169,8 @@ public function testIndexActionRendersValidModulesOnly() $viewVariable = $viewModel->getVariable('repositories'); $this->assertInternalType('array', $viewVariable); - $this->assertCount(2, $viewVariable); - $this->assertSame($validModule, $viewVariable[0]); + $this->assertCount(1, $viewVariable); + $this->assertSame($unregisteredModule, $viewVariable[0]); } public function testOrganizationActionRedirectsIfNotAuthenticated() From 4eecbc37ed6a5bf04a9596785445062bb162108f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 24 Feb 2015 14:09:01 +0100 Subject: [PATCH 4/5] Fix: Yet another test --- .../Controller/IndexControllerTest.php | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php index 01455fe2..17d832bb 100644 --- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php +++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php @@ -280,18 +280,15 @@ public function testOrganizationActionFetches100MostRecentlyUpdatedRepositoriesW $this->assertResponseStatusCode(Http\Response::STATUS_CODE_200); } - public function testOrganizationActionRendersValidModulesOnly() + public function testOrganizationActionRendersUnregisteredModulesOnly() { $this->authenticatedAs(new User()); - $validModule = $this->validModule(); - - $nonModule = $this->nonModule(); + $unregisteredModule = $this->validModule(); $registeredModule = $this->registeredModule(); $repositories = [ - $validModule, - $nonModule, + $unregisteredModule, $registeredModule, $this->forkedModule(), $this->moduleWithoutPushPermissions(), @@ -318,15 +315,8 @@ public function testOrganizationActionRendersValidModulesOnly() ; $moduleService - ->expects($this->any()) + ->expects($this->never()) ->method('isModule') - ->willReturnCallback(function ($repository) use ($nonModule) { - if ($repository !== $nonModule) { - return true; - } - - return false; - }) ; $moduleMapper = $this->getMockBuilder(Mapper\Module::class) @@ -382,8 +372,8 @@ public function testOrganizationActionRendersValidModulesOnly() $viewVariable = $viewModel->getVariable('repositories'); $this->assertInternalType('array', $viewVariable); - $this->assertCount(2, $viewVariable); - $this->assertSame($validModule, $viewVariable[0]); + $this->assertCount(1, $viewVariable); + $this->assertSame($unregisteredModule, $viewVariable[0]); } public function testAddActionRedirectsIfNotAuthenticated() From fa9e0e4b8caa342c8b22ba53b9b57f44c679a31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Tue, 24 Feb 2015 17:36:44 +0100 Subject: [PATCH 5/5] Fix: Remove assertion that isModule() is never called --- .../Integration/Controller/IndexControllerTest.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php index 17d832bb..164c4f4b 100644 --- a/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php +++ b/module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php @@ -116,11 +116,6 @@ public function testIndexActionRendersUnregisteredModulesOnly() ->getMock() ; - $moduleService - ->expects($this->never()) - ->method('isModule') - ; - $moduleMapper = $this->getMockBuilder(Mapper\Module::class) ->disableOriginalConstructor() ->getMock() @@ -314,11 +309,6 @@ public function testOrganizationActionRendersUnregisteredModulesOnly() ->getMock() ; - $moduleService - ->expects($this->never()) - ->method('isModule') - ; - $moduleMapper = $this->getMockBuilder(Mapper\Module::class) ->disableOriginalConstructor() ->getMock()