Completed
Push — master ( 746635...1250b5 )
by Pavel
04:18
created

UpdateControllerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testDeleteAction() 0 37 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 UpdateControllerTest extends AbstractCrudsWebTest
9
{
10
    /**
11
     * @dataProvider getKernelClasses
12
     *
13
     * @param $kernel
14
     */
15
    public function testDeleteAction($kernel)
16
    {
17
        self::createAndBootKernel($kernel);
18
        self::configureDb();
19
20
        $client = self::createClient();
21
        $em     = self::getEntityManager();
22
23
        $entity = new MyEntity('private-data');
24
        $entity->setPublicApiField('public-data');
25
        $em->persist($entity);
26
        $em->flush();
27
        $em->clear();
28
29
30
        $client->request(
31
            'POST',
32
            '/api/entity/my-entity/update',
33
            [
34
                'identifier' => $entity->getId(),
35
                'data'       => [
36
                    'public_api_field' => 'updated-data',
37
                    'parent'           => $entity->getId(),
38
                ],
39
            ],
40
            [],
41
            ['HTTP_CONTENT_TYPE' => 'application/json']
42
        );
43
        $response = $client->getResponse();
44
45
        self::assertTrue($response->isSuccessful());
46
        $em->clear();
47
        $entity = $em->getRepository(MyEntity::class)->find($entity->getId());
48
        self::assertSame('updated-data', $entity->getPublicApiField());
49
        self::assertSame($entity->getParent(), $entity);
50
        self::assertContains($entity, $entity->getChildren());
51
    }
52
}
53