Passed
Push — html ( d230bc...4d98c2 )
by Peter
03:13
created

UrlTest::testToQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
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