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

BomTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetEncoding() 0 4 1
A getEncodingData() 0 10 1
A testGetEncodingWillThrowAnExceptionForUnknownBom() 0 5 1
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