GoodbyCsvProviderTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 39
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 2
A testCountRowsIsValid() 0 4 1
A testcollectColumnSizesIsValid() 0 11 1
1
<?php
2
3
namespace Toa\Component\Validator\Tests\Provider;
4
5
use Toa\Component\Validator\Provider\GoodbyCsvProvider;
6
7
/**
8
 * Class GoodbyCsvProviderTest
9
 *
10
 * @author Enrico Thies <[email protected]>
11
 */
12
class GoodbyCsvProviderTest extends \PHPUnit_Framework_TestCase
13
{
14
    protected $provider;
15
    protected $csv;
16
17
    protected function setUp()
18
    {
19
        if (!class_exists('Goodby\CSV\Import\Standard\Lexer')) {
20
            $this->markTestSkipped('The "GoodbyCsv" component is not available');
21
        }
22
23
        $this->provider = new GoodbyCsvProvider();
24
25
        $this->csv = __DIR__.'/../Constraints/Fixtures/test.csv';
26
    }
27
28
    /**
29
     * @test
30
     */
31
    public function testCountRowsIsValid()
32
    {
33
        $this->assertEquals(3, $this->provider->countRows($this->csv));
34
    }
35
36
    /**
37
     * @test
38
     */
39
    public function testcollectColumnSizesIsValid()
40
    {
41
        $columnSizes = $this->provider->collectColumnSizes($this->csv);
42
43
        $this->assertInternalType('array', $columnSizes);
44
        $this->assertSame($this->provider->collectColumnSizes($this->csv), $columnSizes);
45
        $this->assertCount(1, $columnSizes);
46
        $this->assertArrayHasKey(3, $columnSizes);
47
        $this->assertEquals(array(1, 2, 3), $columnSizes[3]);
48
        $this->assertArrayNotHasKey(0, $columnSizes);
49
    }
50
}
51