Completed
Pull Request — master (#7)
by Harry
02:41
created

BomTest::testGetEncoding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Graze\CsvToken\Test\Unit\Csv;
4
5
use Graze\CsvToken\Csv\Bom;
6
use Graze\CsvToken\Test\TestCase;
7
use InvalidArgumentException;
8
9
class BomTest extends TestCase
10
{
11
    /**
12
     * @dataProvider getEncodingData
13
     *
14
     * @param string $bom
15
     * @param string $expectedEncoding
16
     */
17
    public function testGetEncoding($bom, $expectedEncoding)
18
    {
19
        static::assertEquals($expectedEncoding, Bom::getEncoding($bom));
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function getEncodingData()
26
    {
27
        return [
28
            [Bom::BOM_UTF8, 'UTF-8'],
29
            [Bom::BOM_UTF16_BE, 'UTF-16BE'],
30
            [Bom::BOM_UTF16_LE, 'UTF-16LE'],
31
            [Bom::BOM_UTF32_BE, 'UTF-32BE'],
32
            [Bom::BOM_UTF32_LE, 'UTF-32LE'],
33
        ];
34
    }
35
36
    public function testGetEncodingWillThrowAnExceptionForUnknownBom()
37
    {
38
        static::expectException(InvalidArgumentException::class);
39
        Bom::getEncoding('random');
40
    }
41
}
42