Passed
Push — master ( de60ff...3807db )
by Pavel
09:53
created

RouteAccessibilityTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequests() 0 21 1
A testRequestWasSuccessful() 0 5 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Configuration;
4
5
use ScayTrase\Api\Cruds\Tests\AbstractDbAwareTest;
6
use ScayTrase\Api\Cruds\Tests\Unit\StaticDbTestTrait;
7
use Symfony\Component\BrowserKit\Client;
8
9
class RouteAccessibilityTest extends AbstractDbAwareTest
10
{
11
    use StaticDbTestTrait;
12
13
    public function getRequests()
14
    {
15
        return [
16
            'create' => ['/api/entity/my-entity/create', 'POST', ['data' => ['publicApiField' => 'my-value']]],
17
            'get'    => ['/api/entity/my-entity/get', 'GET', ['identifier' => 1]],
18
            'update' => [
19
                '/api/entity/my-entity/update',
20
                'POST',
21
                [
22
                    'identifier' => 1,
23
                    'data'       => [
24
                        'publicApiField' => 'my-updated-value',
25
                        'parent'         => null,
26
                    ],
27
                ],
28
            ],
29
            'search' => ['/api/entity/my-entity/search', 'GET', ['criteria' => ['id' => 1]]],
30
            'count'  => ['/api/entity/my-entity/count', 'GET', ['criteria' => ['id' => 1]]],
31
            'delete' => ['/api/entity/my-entity/delete', 'POST', ['identifier' => 1]],
32
        ];
33
    }
34
35
    /**
36
     * @dataProvider getRequests
37
     *
38
     * @param string $path
39
     * @param string $method
40
     * @param array  $args
41
     */
42
    public function testRequestWasSuccessful($path, $method, array $args = [])
43
    {
44
        self::$client->request($method, $path, $args);
45
        self::assertTrue(self::$client->getResponse()->isSuccessful());
46
    }
47
}
48