Completed
Push — master ( 9e925c...214c62 )
by Pavel
03:41
created

IndirectFieldsTestAbstract   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 90 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 6
dl 27
loc 30
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Bankiru\Api\Tests;
4
5
use Bankiru\Api\Test\Entity\IndirectIdEntity;
6
use GuzzleHttp\Psr7\Response;
7
8
class IndirectFieldsTestAbstract extends AbstractEntityManagerTest
9
{
10 1
    public function testIndirectId()
11
    {
12 1
        $repository = $this->getManager()->getRepository(IndirectIdEntity::class);
13 1
        $this->getResponseMock()->append(
14 1
            new Response(
15 1
                200,
16 1
                [],
17 1
                json_encode(
18
                    [
19 1
                        'jsonrpc' => '2.0',
20 1
                        'id'      => 'test',
21
                        'result'  => [
22 1
                            'some-long-api-field-name' => 241,
23 1
                            'payload'                  => 'test',
24 1
                        ],
25
                    ]
26 1
                )
27 1
            )
28 1
        );
29
30
        /** @var IndirectIdEntity $entity */
31 1
        $entity = $repository->find(241);
32
33 1
        self::assertInstanceOf(IndirectIdEntity::class, $entity);
34 1
        self::assertEquals(241, $entity->getId());
35 1
        self::assertEquals('test', $entity->getPayload());
36 1
    }
37
}
38