Completed
Pull Request — master (#144)
by Markus
02:45 queued 01:47
created

StringValueTest::provideTestData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
c 0
b 0
f 0
rs 9.552
nc 1
cc 1
nop 0
1
<?php
2
3
namespace Eluceo\iCal\Test\Unit\Presentation\Component\Property\Value;
4
5
use Eluceo\iCal\Presentation\Component\Property\Value\StringValue;
6
use PHPUnit\Framework\TestCase;
7
8
class StringValueTest extends TestCase
9
{
10
    /**
11
     * @dataProvider provideTestData
12
     */
13
    public function testStringValueEscaping(string $inputValue, string $expected)
14
    {
15
        self::assertSame($expected, (string)StringValue::fromString($inputValue));
16
    }
17
18
    public function provideTestData()
19
    {
20
        yield 'no escaping needed' => [
21
            'LOREM',
22
            'LOREM',
23
        ];
24
        yield 'backslashes are escaped' => [
25
            'text contains backslash: \\',
26
            'text contains backslash: \\\\',
27
        ];
28
        yield 'double quotes are escaped' => [
29
            'text with "doublequotes" will be escaped',
30
            'text with \\"doublequotes\\" will be escaped'
31
        ];
32
        yield 'semicolon and comma are escaped' => [
33
            'text with , and ; will also be escaped',
34
            'text with \\, and \\; will also be escaped',
35
        ];
36
        yield 'new lines are escaped' => [
37
            "Text with new\n line",
38
            'Text with new\\n line',
39
        ];
40
    }
41
}
42