ArrayProviderTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testWrongArray() 0 4 1
A testInconsistentArray() 0 13 1
A testGetEstimatedSize() 0 15 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlow\Provider;
5
6
use PHPUnit\Framework\TestCase;
7
8
class ArrayProviderTest extends TestCase
9
{
10
    /**
11
     * @expectedException \SlayerBirden\DataFlow\Provider\InvalidDataException
12
     * @expectedExceptionMessage Row #(0) is not an array
13
     */
14
    public function testWrongArray()
15
    {
16
        new ArrayProvider('test1', [1,2,3]);
17
    }
18
19
    /**
20
     * @expectedException \SlayerBirden\DataFlow\Provider\InvalidDataException
21
     * @expectedExceptionMessage Row #(1) has different structure than the 1st element
22
     */
23
    public function testInconsistentArray()
24
    {
25
        new ArrayProvider('test2', [
26
            [
27
                'id' => 1,
28
                'name' => 'Bob',
29
            ],
30
            [
31
                'id' => 2,
32
                'gender' => 'male',
33
            ]
34
        ]);
35
    }
36
37
    public function testGetEstimatedSize()
38
    {
39
        $provider = new ArrayProvider('test2', [
40
            [
41
                'id' => 1,
42
                'name' => 'Bob',
43
            ],
44
            [
45
                'name' => 'Peter',
46
                'id' => 2,
47
            ]
48
        ]);
49
50
        $this->assertSame(2, $provider->getEstimatedSize());
51
    }
52
}
53