From 52d38a0c84d3f01f7db5c783ca049d4d74aec2a7 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Tue, 29 Jan 2019 21:01:01 +0100 Subject: [PATCH] Implemented Tests for ActionHttpMethodMap --- .../ActionHttpMethodMap.php | 3 +- .../ActionHttpMethodMapInterface.php | 2 +- .../MapManagement/ActionHttpMethodTest.php | 58 +++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) rename application/symfony/src/Domain/{ResponseManagement => MapManagement}/ActionHttpMethodMap.php (92%) rename application/symfony/src/Domain/{ResponseManagement => MapManagement}/ActionHttpMethodMapInterface.php (92%) create mode 100644 application/symfony/tests/Unit/Domain/MapManagement/ActionHttpMethodTest.php diff --git a/application/symfony/src/Domain/ResponseManagement/ActionHttpMethodMap.php b/application/symfony/src/Domain/MapManagement/ActionHttpMethodMap.php similarity index 92% rename from application/symfony/src/Domain/ResponseManagement/ActionHttpMethodMap.php rename to application/symfony/src/Domain/MapManagement/ActionHttpMethodMap.php index 812ae19..01f8338 100644 --- a/application/symfony/src/Domain/ResponseManagement/ActionHttpMethodMap.php +++ b/application/symfony/src/Domain/MapManagement/ActionHttpMethodMap.php @@ -1,8 +1,7 @@ assertEquals($expectedResult, in_array($value, $haystack)); + } + } + + public function testCreateActionTrue(): void + { + $subset = [Request::METHOD_GET, Request::METHOD_POST]; + $action = ActionType::CREATE; + $haystack = ActionHttpMethodMap::getHttpMethods($action); + $this->assertSubsetInArray($subset, $haystack, true); + $this->assertEquals(2, count($haystack)); + } + + public function testCreateActionFalse(): void + { + $subset = [Request::METHOD_GET, Request::METHOD_POST]; + $action = 'wrong value'; + $haystack = ActionHttpMethodMap::getHttpMethods($action); + $this->assertSubsetInArray($subset, $haystack, false); + } + + public function testPostMethodTrue(): void + { + $subset = [ActionType::READ]; + $httpMethod = Request::METHOD_GET; + $haystack = ActionHttpMethodMap::getActions($httpMethod); + $this->assertSubsetInArray($subset, $haystack, true); + } + + public function testPostMethodFalse(): void + { + $subset = [ActionType::READ]; + $httpMethod = 'wrong value'; + $haystack = ActionHttpMethodMap::getActions($httpMethod); + $this->assertSubsetInArray($subset, $haystack, false); + } +}