Completed
Push — master ( 8ce185...772880 )
by Pavel
04:21
created

AccessTest::setUpBeforeClass()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 28
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\Tools\SchemaTool;
7
use Doctrine\ORM\Tools\SchemaValidator;
8
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
9
10
class AccessTest extends WebTestCase
11
{
12
    use CrudsTestCaseTrait;
13
14
    /**
15
     * @dataProvider getKernelClasses
16
     *
17
     * @param $kernel
18
     */
19
    public function testEntityRouting($kernel)
20
    {
21
        self::setKernelClass($kernel);
22
        self::configureDb();
23
24
        $this->doRequest('/api/entity/my-entity/create', 'POST', ['data' => ['publicApiField' => 'my-value']]);
25
        $this->doRequest('/api/entity/my-entity/read', 'GET', ['identifier' => 1]);
26
        $this->doRequest(
27
            '/api/entity/my-entity/update',
28
            'POST',
29
            [
30
                'identifier' => 1,
31
                'data'       => [
32
                    'publicApiField' => 'my-updated-value',
33
                    'parent'         => 1,
34
                ],
35
            ]
36
        );
37
38
        $this->doRequest('/api/entity/my-entity/search', 'GET', ['criteria' => []]);
39
        $this->doRequest('/api/entity/my-entity/delete', 'POST', ['identifier' => 1]);
40
    }
41
42
    private function doRequest($path, $method, array $args = [])
43
    {
44
        $client = self::createClient();
45
        $client->request($method, $path, $args);
46
47
        echo ($path);
48
        echo (PHP_EOL);
49
        echo ((string)$client->getResponse());
50
        echo (PHP_EOL);
51
        echo (PHP_EOL);
52
        echo (PHP_EOL);
53
    }
54
}
55