RouteAccessibilityTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Configuration;
4
5
use ScayTrase\Api\Cruds\Tests\Fixtures\Common\Entity\MyEntity;
6
use ScayTrase\Api\Cruds\Tests\WebTestCase;
7
use Symfony\Bundle\FrameworkBundle\Client;
8
9
final class RouteAccessibilityTest extends WebTestCase
10
{
11
    /** @var Client */
12
    private static $client;
13
14
    public static function setUpBeforeClass()
15
    {
16
        self::$client = self::createClient();
17
    }
18
19
    public function getRequests()
20
    {
21
        return [
22
            'create' => ['/api/entity/my-entity/create', 'POST', ['data' => ['publicApiField' => 'my-value']]],
23
            'get'    => ['/api/entity/my-entity/get', 'GET', ['identifier' => 1]],
24
            'update' => [
25
                '/api/entity/my-entity/update',
26
                'POST',
27
                [
28
                    'identifier' => 1,
29
                    'data'       => [
30
                        'publicApiField' => 'my-updated-value',
31
                        'parent'         => null,
32
                    ],
33
                ],
34
            ],
35
            'search' => ['/api/entity/my-entity/search', 'GET', ['criteria' => ['id' => 1]]],
36
            'count'  => ['/api/entity/my-entity/count', 'GET', ['criteria' => ['id' => 1]]],
37
            'delete' => ['/api/entity/my-entity/delete', 'POST', ['identifier' => 1]],
38
        ];
39
    }
40
41
    /**
42
     * @dataProvider getRequests
43
     *
44
     * @param string $path
45
     * @param string $method
46
     * @param array  $args
47
     */
48
    public function testRequestWasSuccessful($path, $method, array $args = [])
49
    {
50
        self::$client->request($method, $path, $args);
51
        self::assertTrue(self::$client->getResponse()->isSuccessful());
52
    }
53
54
    protected function setUp()
55
    {
56
        $this->loadFixtures([]);
57
        $entity = new MyEntity();
58
        $this->getEntityManager()->persist($entity);
59
        $this->getEntityManager()->flush();
60
    }
61
}
62