Completed
Pull Request — master (#580)
by Greg
03:19
created

ResultDataTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testResultDataUpdate() 0 13 1
A testResultDataMergeData() 0 16 2
1
<?php
2
3
use Robo\ResultData;
4
5
/**
6
 * Class ResultDataTest.
7
 *
8
 * @coversDefaultClass \Robo\ResultData
9
 */
10
class ResultDataTest extends \Codeception\Test\Unit
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /**
13
     * @var \CodeGuy
14
     */
15
    protected $guy;
16
17
    public function testResultDataUpdate()
18
    {
19
        $a = new ResultData(ResultData::EXITCODE_OK, '', ['one' => 'first', 'two' => 'second']);
20
        $b = new ResultData(ResultData::EXITCODE_OK, '', ['one' => 'First', 'three' => 'Third']);
21
22
        $expected = ['one' => 'first', 'two' => 'second'];
23
        $this->guy->assertEquals($expected, $a->getData());
24
25
        $a->update($b);
26
27
        $expected = ['one' => 'First', 'two' => 'second', 'three' => 'Third'];
28
        $this->guy->assertEquals($expected, $a->getData());
29
    }
30
31
    public function testResultDataMergeData()
32
    {
33
        $a = new ResultData(ResultData::EXITCODE_OK, '', ['one' => 'first', 'two' => 'second']);
34
35
        $to_be_merged = [
36
            ['one' => 'ignored',],
37
            ['three' => 'new',],
38
        ];
39
40
        foreach ($to_be_merged as $mergeThis) {
41
            $a->mergeData($mergeThis);
42
        }
43
44
        $expected = ['one' => 'first', 'two' => 'second', 'three' => 'new'];
45
        $this->guy->assertEquals($expected, $a->getData());
46
    }
47
}
48