getColumnsFromEmptyLine()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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