Passed
Pull Request — main (#3)
by Peter
07:02 queued 03:23
created

ArrayHelperTest::toAttributesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 16
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Html\Helper;
6
7
use PHPUnit\Framework\TestCase;
8
9
class ArrayHelperTest extends TestCase
10
{
11
    public function toStylesProvider(): array
12
    {
13
        return [
14
            'empty' => [[], ''],
15
            'one'   => [['color' => 'red'], 'color: red'],
16
            'three' => [
17
                ['color' => 'red', 'background' => 'none', 'font-weight' => 'bold'],
18
                'color: red; background: none; font-weight: bold',
19
            ],
20
        ];
21
    }
22
23
    /**
24
     * @dataProvider toStylesProvider
25
     *
26
     * @param array  $styles
27
     * @param string $expectedResult
28
     */
29
    public function testToStyles(array $styles, string $expectedResult): void
30
    {
31
        $actualResult = ArrayHelper::toStyles($styles);
32
33
        $this->assertEquals($expectedResult, $actualResult);
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function toQueryProvider(): array
40
    {
41
        return [
42
            'empty'   => [[], ''],
43
            'simple'  => [['key' => 'value'], '?key=value'],
44
            'default' => [['key1' => 'value1', 'key2' => 'value2'], '?key1=value1&key2=value2'],
45
            'complex' => [['key1' => 'value1ő', 'key2' => 'value2'], '?key1=value1%C5%91&key2=value2'],
46
        ];
47
    }
48
49
    /**
50
     * @dataProvider toQueryProvider
51
     *
52
     * @param array  $parts
53
     * @param string $expectedResult
54
     */
55
    public function testToQuery(array $parts, string $expectedResult): void
56
    {
57
        $actualResult = ArrayHelper::toQuery($parts);
58
59
        $this->assertEquals($expectedResult, $actualResult);
60
    }
61
}
62