Passed
Pull Request — main (#4)
by Peter
03:15
created

UrlTest::toQueryProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Helper;
6
7
use PHPUnit\Framework\TestCase;
8
9
class UrlTest extends TestCase
10
{
11
    /**
12
     * @return array[]
13
     */
14
    public function toQueryProvider(): array
15
    {
16
        return [
17
            'empty'  => [[], ''],
18
            'simple' => [['foo' => 'Foo'], '?foo=Foo'],
19
            'unsafe' => [['foo' => 'Foo&Bar'], '?foo=Foo%26Bar'],
20
            'complex' => [['foo' => 'Foo&Bar', 'bar' => 'Bar=Baz'], '?foo=Foo%26Bar&bar=Bar%3DBaz'],
21
        ];
22
    }
23
24
    /**
25
     * @dataProvider toQueryProvider
26
     *
27
     * @param array  $parts
28
     * @param string $expectedResult
29
     */
30
    public function testToQuery(array $parts, string $expectedResult): void
31
    {
32
        $actualResult = Url::toQuery($parts);
33
34
        $this->assertSame($expectedResult, $actualResult);
35
    }
36
}
37