|
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; |
|
13
|
|
|
|
|
14
|
|
|
use Eluceo\iCal\Presentation\Component\Property; |
|
15
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Parameter; |
|
16
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Value; |
|
17
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Value\TextValue; |
|
18
|
|
|
use PHPUnit\Framework\TestCase; |
|
19
|
|
|
|
|
20
|
|
|
class PropertyTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @dataProvider provideTestData |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testPropertyToString(string $name, Value $value, array $parameters, string $expected) |
|
26
|
|
|
{ |
|
27
|
|
|
self::assertSame($expected, (string) Property::create($name, $value, $parameters)); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function provideTestData() |
|
31
|
|
|
{ |
|
32
|
|
|
yield 'property with simple value' => [ |
|
33
|
|
|
'LOREM', |
|
34
|
|
|
TextValue::fromString('Ipsum'), |
|
35
|
|
|
[], |
|
36
|
|
|
'LOREM:Ipsum', |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
yield 'property with parameters' => [ |
|
40
|
|
|
'LOREM', |
|
41
|
|
|
TextValue::fromString('Ipsum'), |
|
42
|
|
|
[ |
|
43
|
|
|
Parameter::create('TEST', TextValue::fromString('value')), |
|
44
|
|
|
], |
|
45
|
|
|
'LOREM:TEST=value:Ipsum', |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
yield 'property with multiple parameters' => [ |
|
49
|
|
|
'LOREM', |
|
50
|
|
|
TextValue::fromString('Ipsum'), |
|
51
|
|
|
[ |
|
52
|
|
|
Parameter::create('TEST', TextValue::fromString('value')), |
|
53
|
|
|
Parameter::create('TEST2', TextValue::fromString('value2')), |
|
54
|
|
|
], |
|
55
|
|
|
'LOREM:TEST=value;TEST2=value2:Ipsum', |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|