Passed
Push — master ( 7438ce...69adc8 )
by Guilherme
01:29 queued 11s
created

UrlHelperTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\LoginCidadao\NfgBundle\Tests\Helper;
12
13
use PHPUnit\Framework\TestCase;
14
use PROCERGS\LoginCidadao\NfgBundle\Helper\UrlHelper;
15
16
class UrlHelperTest extends TestCase
17
{
18
    public function testAddToEmptyQuery()
19
    {
20
        $url = parse_url('https://dum.my/something');
21
        $query = isset($url['query']) ? $url['query'] : null;
22
23
        $data = ['key1' => 'val1', 'key2' => 'val2'];
24
        $expected = http_build_query($data);
25
        $result = UrlHelper::addToQuery($data, $query);
26
27
        $this->assertEquals($expected, $result);
28
    }
29
30
    public function testAddToQuery()
31
    {
32
        $url = parse_url('https://dum.my/something?foo=bar');
33
        $query = $url['query'];
34
35
        $result = UrlHelper::addToQuery(['key1' => 'val1'], $query);
36
37
        $this->assertContains('bar', $result);
38
        $this->assertContains('val1', $result);
39
    }
40
}
41