Passed
Push — master ( 14b05a...fa6902 )
by Daniel
02:41
created

CsvOptionsTest::testSetDelimiter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * This file is part of the Csv-Machine package.
5
 *
6
 * (c) Dan McAdams <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace RoadBunch\Csv\Tests\Csv;
13
14
15
use PHPUnit\Framework\TestCase;
16
use RoadBunch\Csv as Csv;
17
18
/**
19
 * Class CsvTest
20
 *
21
 * @author  Dan McAdams
22
 * @package RoadBunch\Csv\Tests\Csv
23
 */
24
class CsvOptionsTest extends TestCase
25
{
26
    public function testDefaultOptions()
27
    {
28
        $csv = new CsvSpy();
29
        $this->assertEquals(Csv\Delimiter::DELIMITER_COMMA          , $csv->getDelimiter());
30
        $this->assertEquals(Csv\Enclosure::ENCLOSURE_DOUBLE_QUOTE   , $csv->getEnclosure());
31
        $this->assertEquals(Csv\Newline::NEWLINE_LF                 , $csv->getNewline());
32
        $this->assertEquals(Csv\Escape::ESCAPE_CHAR                 , $csv->getEscapeCharacter());
33
    }
34
35
    public function testSetDelimiter()
36
    {
37
        $csv           = new CsvSpy();
38
        $testDelimiter = Csv\Delimiter::DELIMITER_COLON;
39
40
        $csv->setDelimiter($testDelimiter);
41
        $this->assertEquals($testDelimiter, $csv->getDelimiter());
42
    }
43
44
    public function testSetEnclosure()
45
    {
46
        $csv           = new CsvSpy();
47
        $testEnclosure = Csv\Enclosure::ENCLOSURE_SINGLE_QUOTE;
48
49
        $csv->setEnclosure($testEnclosure);
50
        $this->assertEquals($testEnclosure, $csv->getEnclosure());
51
    }
52
53
    public function testSetNewline()
54
    {
55
        $csv         = new CsvSpy();
56
        $testNewline = Csv\Newline::NEWLINE_CRLF;
57
58
        $csv->setNewline($testNewline);
59
        $this->assertEquals($testNewline, $csv->getNewline());
60
    }
61
62
    public function testSetEscape()
63
    {
64
        $csv        = new CsvSpy();
65
        $testEscape = "esc";
66
67
        $csv->setEscape($testEscape);
68
        $this->assertEquals($testEscape, $csv->getEscapeCharacter());
69
    }
70
}
71