mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Implemented Tests for ActionHttpMethodMap
This commit is contained in:
parent
8e2d79d236
commit
52d38a0c84
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Domain\ResponseManagement;
|
namespace App\Domain\MapManagement;
|
||||||
|
|
||||||
use App\Domain\MapManagement\AbstractMap;
|
|
||||||
use App\DBAL\Types\ActionType;
|
use App\DBAL\Types\ActionType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Domain\ResponseManagement;
|
namespace App\Domain\MapManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class offers a map for ActionTypes to HttpMethods.
|
* This class offers a map for ActionTypes to HttpMethods.
|
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace tests\Unit\Domain\MapManagement;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use App\Domain\MapManagement\ActionHttpMethodMap;
|
||||||
|
use App\DBAL\Types\ActionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class ActionHttpMethodTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array|string[] $subset
|
||||||
|
* @param array $haystack|string[]
|
||||||
|
*/
|
||||||
|
private function assertSubsetInArray(array $subset, array $haystack, bool $expectedResult)
|
||||||
|
{
|
||||||
|
foreach ($subset as $value) {
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user