Passed
Push — master ( 7dc692...212065 )
by Sylvain
02:20
created

FormatTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 38
rs 10
c 3
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A truncateProvider() 0 8 1
A testTruncate() 0 4 1
A removeAccentsProvider() 0 6 1
A testRemoveAccents() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix;
6
7
use Ecodev\Felix\Format;
8
9
final class FormatTest extends \PHPUnit\Framework\TestCase
10
{
11
    public function truncateProvider(): array
12
    {
13
        return [
14
            [['abcdef', 100], 'abcdef'],
15
            [['abcdef', 6], 'abcdef'],
16
            [['abcdef', 3], 'ab…'],
17
            [['abcdef', 3, ''], 'abc'],
18
            [['abcdefghi', 5, 'foo'], 'abfoo'],
19
        ];
20
    }
21
22
    /**
23
     * @dataProvider truncateProvider
24
     */
25
    public function testTruncate(array $args, string $expected): void
26
    {
27
        $actual = Format::truncate(...$args);
28
        self::assertSame($expected, $actual);
29
    }
30
31
    public function removeAccentsProvider(): array
32
    {
33
        return [
34
            ['Škoda', 'Skoda'],
35
            ["L'épicerie de la Côte", "L'epicerie de la Cote"],
36
            ['Zürich', 'Zurich'],
37
        ];
38
    }
39
40
    /**
41
     * @dataProvider removeAccentsProvider
42
     */
43
    public function testRemoveAccents(string $input, string $expected): void
44
    {
45
        $actual = Format::removeAccents($input);
46
        self::assertSame($expected, $actual);
47
    }
48
}
49