Completed
Pull Request — master (#144)
by Markus
01:01
created

ListValueTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 38
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testStringValueEscaping() 0 4 1
A provideTestData() 0 27 1
1
<?php
2
3
/*
4
 * This file is part of the eluceo/iCal package.
5
 *
6
 * (c) 2019 Markus Poerschke <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Eluceo\iCal\Test\Unit\Presentation\Component\Property\Value;
13
14
use Eluceo\iCal\Presentation\Component\Property\Value\ListValue;
15
use Eluceo\iCal\Presentation\Component\Property\Value\TextValue;
16
use PHPUnit\Framework\TestCase;
17
18
class ListValueTest extends TestCase
19
{
20
    /**
21
     * @dataProvider provideTestData
22
     */
23
    public function testStringValueEscaping(array $values, string $expected)
24
    {
25
        self::assertSame($expected, (string) ListValue::fromStringValues($values));
26
    }
27
28
    public function provideTestData()
29
    {
30
        yield 'empty list value' => [
31
            [],
32
            '',
33
        ];
34
        yield 'single value' => [
35
            [TextValue::fromString('Lorem')],
36
            'Lorem',
37
        ];
38
        yield 'multiple values without escaping' => [
39
            [
40
                TextValue::fromString('Lorem'),
41
                TextValue::fromString('Ipsum'),
42
                TextValue::fromString('Dolor'),
43
            ],
44
            'Lorem,Ipsum,Dolor',
45
        ];
46
        yield 'multiple values with escaping' => [
47
            [
48
                TextValue::fromString('Lorem'),
49
                TextValue::fromString('Ips,um'),
50
                TextValue::fromString('semi;colon:'),
51
            ],
52
            'Lorem,Ips\\,um,semi\\;colon:',
53
        ];
54
    }
55
}
56