Completed
Pull Request — master (#18)
by Chad
01:19
created

getColumnsFromEmptyLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace DominionEnterprises\ColumnParser\LineParser;
3
4
use PHPUnit\Framework\TestCase;
5
6
/**
7
 * @coversDefaultClass \DominionEnterprises\ColumnParser\LineParser\StrictColumnWidthsParser
8
 */
9
class StrictColumnWidthsParserTest extends TestCase
10
{
11
    /**
12
     * This tests the basic getColumns behavior.
13
     *
14
     * @test
15
     * @covers ::__construct
16
     * @covers ::getColumns
17
     */
18
    public function getColumnsFromSampleLine()
19
    {
20
        $parser = new StrictColumnWidthsParser([9, 5, 13]);
21
        $this->assertSame(['James', '17', 'San Francisco, CA'], $parser->getColumns('James    17   San Francisco, CA'));
22
    }
23
24
    /**
25
     * This tests the getColumns behavior for an empty row.
26
     *
27
     * @test
28
     * @covers ::__construct
29
     * @covers ::getColumns
30
     */
31
    public function getColumnsFromEmptyLine()
32
    {
33
        $parser = new StrictColumnWidthsParser([9, 5, 13]);
34
        $this->assertSame(['', '', ''], $parser->getColumns(''));
35
    }
36
37
    /**
38
     * This tests the getColumns behavior for a row with fewer columns than in the columnWidths spec.
39
     *
40
     * @test
41
     * @covers ::__construct
42
     * @covers ::getColumns
43
     */
44
    public function getColumnsFromShortLine()
45
    {
46
        $parser = new StrictColumnWidthsParser([9, 5, 13]);
47
        $this->assertSame(['Mary', '18', ''], $parser->getColumns('Mary     18'));
48
    }
49
}
50