1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of graze/csv-token |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/graze/csv-token/blob/master/LICENSE.md |
11
|
|
|
* @link https://github.com/graze/csv-token |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Graze\CsvToken\Test\Unit\Csv; |
15
|
|
|
|
16
|
|
|
use Graze\CsvToken\Csv\Bom; |
17
|
|
|
use Graze\CsvToken\Test\TestCase; |
18
|
|
|
use InvalidArgumentException; |
19
|
|
|
|
20
|
|
|
class BomTest extends TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @dataProvider getEncodingData |
24
|
|
|
* |
25
|
|
|
* @param string $bom |
26
|
|
|
* @param string $expectedEncoding |
27
|
|
|
*/ |
28
|
|
|
public function testGetEncoding($bom, $expectedEncoding) |
29
|
|
|
{ |
30
|
|
|
static::assertEquals($expectedEncoding, Bom::getEncoding($bom)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return array |
35
|
|
|
*/ |
36
|
|
|
public function getEncodingData() |
37
|
|
|
{ |
38
|
|
|
return [ |
39
|
|
|
[Bom::BOM_UTF8, 'UTF-8'], |
40
|
|
|
[Bom::BOM_UTF16_BE, 'UTF-16BE'], |
41
|
|
|
[Bom::BOM_UTF16_LE, 'UTF-16LE'], |
42
|
|
|
[Bom::BOM_UTF32_BE, 'UTF-32BE'], |
43
|
|
|
[Bom::BOM_UTF32_LE, 'UTF-32LE'], |
44
|
|
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetEncodingWillThrowAnExceptionForUnknownBom() |
48
|
|
|
{ |
49
|
|
|
static::expectException(InvalidArgumentException::class); |
50
|
|
|
Bom::getEncoding('random'); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|