Completed
Pull Request — master (#144)
by Markus
02:45 queued 01:47
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
namespace Eluceo\iCal\Test\Unit\Presentation\Component\Property\Value;
4
5
use Eluceo\iCal\Presentation\Component\Property\Value\ListValue;
6
use Eluceo\iCal\Presentation\Component\Property\Value\StringValue;
7
use PHPUnit\Framework\TestCase;
8
9
class ListValueTest extends TestCase
10
{
11
    /**
12
     * @dataProvider provideTestData
13
     */
14
    public function testStringValueEscaping(array $values, string $expected)
15
    {
16
        self::assertSame($expected, (string)ListValue::fromStringValues($values));
17
    }
18
19
    public function provideTestData()
20
    {
21
        yield 'empty list value' => [
22
            [],
23
            '',
24
        ];
25
        yield 'single value' => [
26
            [StringValue::fromString('Lorem')],
27
            'Lorem'
28
        ];
29
        yield 'multiple values without escaping' => [
30
            [
31
                StringValue::fromString('Lorem'),
32
                StringValue::fromString('Ipsum'),
33
                StringValue::fromString('Dolor')
34
            ],
35
            'Lorem,Ipsum,Dolor'
36
        ];
37
        yield 'multiple values with escaping' => [
38
            [
39
                StringValue::fromString('Lorem'),
40
                StringValue::fromString('Ips,um'),
41
                StringValue::fromString('"doublequotes"')
42
            ],
43
            'Lorem,Ips\,um,\"doublequotes\"'
44
        ];
45
    }
46
}
47