1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Eluceo\iCal\Test\Unit\Presentation\Component; |
4
|
|
|
|
5
|
|
|
use Eluceo\iCal\Presentation\Component\Property; |
6
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Value; |
7
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Parameter; |
8
|
|
|
use Eluceo\iCal\Presentation\Component\Property\Value\StringValue; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class PropertyTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @dataProvider provideTestData |
15
|
|
|
*/ |
16
|
|
|
public function testPropertyToString(string $name, Value $value, array $parameters, string $expected) |
17
|
|
|
{ |
18
|
|
|
self::assertSame($expected, (string)Property::create($name, $value, $parameters)); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function provideTestData() |
22
|
|
|
{ |
23
|
|
|
yield 'property with simple value' => [ |
24
|
|
|
'LOREM', |
25
|
|
|
StringValue::fromString('Ipsum'), |
26
|
|
|
[], |
27
|
|
|
'LOREM:Ipsum', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
yield 'property with parameters' => [ |
31
|
|
|
'LOREM', |
32
|
|
|
StringValue::fromString('Ipsum'), |
33
|
|
|
[ |
34
|
|
|
Parameter::create('TEST', StringValue::fromString('value')), |
35
|
|
|
], |
36
|
|
|
'LOREM:TEST=value:Ipsum', |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
yield 'property with multiple parameters' => [ |
40
|
|
|
'LOREM', |
41
|
|
|
StringValue::fromString('Ipsum'), |
42
|
|
|
[ |
43
|
|
|
Parameter::create('TEST', StringValue::fromString('value')), |
44
|
|
|
Parameter::create('TEST2', StringValue::fromString('value2')), |
45
|
|
|
], |
46
|
|
|
'LOREM:TEST=value;TEST2=value2:Ipsum', |
47
|
|
|
]; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|