Completed
Push — master ( 07e238...0f15f1 )
by Pavel
09:14
created

CountControllerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 40
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testCountAction() 0 32 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Controller;
4
5
use ScayTrase\Api\Cruds\Tests\AbstractCrudsWebTest;
6
use ScayTrase\Api\Cruds\Tests\Fixtures\Common\Entity\MyEntity;
7
8
class CountControllerTest extends AbstractCrudsWebTest
9
{
10
    /**
11
     * @dataProvider getKernelClasses
12
     *
13
     * @param $kernel
14
     */
15
    public function testCountAction($kernel)
16
    {
17
        self::createAndBootKernel($kernel);
18
        self::configureDb();
19
20
        $em     = self::getEntityManager();
21
        $entity = new MyEntity('my-test-secret');
22
        $em->persist($entity);
23
        $parent = new MyEntity('non-recursing-entity');
24
        $em->persist($parent);
25
        $entity->setParent($parent);
26
        $em->flush();
27
        $em->clear();
28
29
        $client = self::createClient();
30
        $client->request(
31
            'GET',
32
            '/api/entity/my-entity/count',
33
            [
34
                'criteria' => [],
35
            ],
36
            [],
37
            ['HTTP_CONTENT_TYPE' => 'application/json']
38
        );
39
        $response = $client->getResponse();
40
41
        self::assertTrue($response->isSuccessful());
42
        $data = json_decode($response->getContent());
43
44
        self::assertEquals(JSON_ERROR_NONE, json_last_error());
45
        self::assertEquals(2, $data);
46
    }
47
}
48