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

ResultDataTest::testResultDataMergeData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
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