Completed
Branch master (1820a0)
by Oss
02:45
created

ParameterTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 32.2 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 19
loc 59
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 Test\Brownie\BpmOnline\DataService\Column\Expression;
4
5
use Brownie\BpmOnline\DataService\Column\Expression\Parameter;
6
use PHPUnit\Framework\TestCase;
7
8
class ParameterTest extends TestCase
9
{
10
11
    /**
12
     * @var Parameter
13
     */
14
    private $parameter;
15
16
    protected function setUp()
17
    {
18
        $this->parameter = new Parameter('Test', Parameter::TEXT);
19
    }
20
21
    protected function tearDown()
22
    {
23
        $this->parameter = null;
24
    }
25
26
    public function testGetKeyName()
27
    {
28
        $this->assertEquals('Parameter', $this->parameter->getKeyName());
29
    }
30
31
    public function testSetGetValue()
32
    {
33
        $parameter = $this->parameter->setValue('TestString');
34
        $this->assertInstanceOf(Parameter::class, $parameter);
35
        $this->assertEquals([
36
            'DataValueType' => 1,
37
            'Value' => 'TestString'
38
        ], $this->parameter->getValue());
39
    }
40
41
    public function testArrayValue()
42
    {
43
        $parameter = $this->parameter->setArrayValue([
44
            'test' => 'ok'
45
        ]);
46
        $this->assertInstanceOf(Parameter::class, $parameter);
47
        $this->assertEquals([
48
            'DataValueType' => 1,
49
            'Value' => 'Test',
50
            'ArrayValue' => [
51
                'test' => 'ok',
52
            ],
53
        ], $this->parameter->getValue());
54
    }
55
56
    public function testShouldSkipConvertion()
57
    {
58
        $parameter = $this->parameter->setShouldSkipConvertion(true);
59
        $this->assertInstanceOf(Parameter::class, $parameter);
60
        $this->assertEquals([
61
            'DataValueType' => 1,
62
            'Value' => 'Test',
63
            'ShouldSkipConvertion' => true,
64
        ], $this->parameter->getValue());
65
    }
66
}
67