Failed Conditions
Pull Request — master (#31)
by Chad
01:33
created

NoHeaderStrategyTest::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace SubjectivePHPTest\Csv;
4
5
use SplFileObject;
6
use SubjectivePHP\Csv\NoHeaderStrategy;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @coversDefaultClass \SubjectivePHP\Csv\NoHeaderStrategy
11
 */
12
final class NoHeaderStrategyTest extends TestCase
13
{
14
    /**
15
     * @test
16
     * @covers ::getHeaders
17
     */
18
    public function getHeaders()
19
    {
20
        $fileObject = new SplFileObject(__DIR__ . '/_files/no_headers.csv');
21
        $fileObject->setFlags(SplFileObject::READ_CSV);
22
        $fileObject->setCsvControl(',');
23
        $strategy = new NoHeaderStrategy();
24
        $this->assertSame(
25
            [0, 1, 2, 3, 4, 5, 6],
26
            $strategy->getHeaders($fileObject)
27
        );
28
    }
29
30
    /**
31
     * @test
32
     * @covers ::isHeaderRow
33
     */
34
    public function isHeaderRowAlwaysReturnsFalse()
35
    {
36
        $fileObject = new SplFileObject(__DIR__ . '/_files/no_headers.csv');
37
        $fileObject->setFlags(SplFileObject::READ_CSV);
38
        $fileObject->setCsvControl(',');
39
        $strategy = new NoHeaderStrategy();
40
        $this->assertFalse($strategy->isHeaderRow($fileObject->fgetcsv()));
41
        $this->assertFalse($strategy->isHeaderRow($fileObject->fgetcsv()));
42
    }
43
}
44