Passed
Push — master ( 4870c3...732c37 )
by Petr
07:47
created

BasicTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 2
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_address_handler\Handler;
8
use kalanis\kw_address_handler\SingleVariable;
9
use kalanis\kw_address_handler\Sources;
10
11
12
class BasicTest extends CommonTestClass
13
{
14
    public function testEmptySources(): void
15
    {
16
        $handler = new Handler();
17
        $this->assertNull($handler->getSource());
18
        $this->assertNull($handler->getAddress());
19
        $this->assertNotNull($handler->getParams());
20
21
        $handler = new Handler(new Sources\Sources());
22
        $this->assertNotEmpty($handler->getSource());
23
        $this->assertEquals('?', $handler->getAddress());
24
        $this->assertNotEmpty($handler->getParams());
25
        $this->assertEquals([], $handler->getParams()->getParamsData());
26
    }
27
28
    public function testBasic(): void
29
    {
30
        $handler = new Handler(new Sources\Address('//abc/def//?ghi=jkl&mno=pqr&stu=vwx'));
31
        $this->assertNotEmpty($handler->getSource());
32
        $this->assertNotEmpty($handler->getParams());
33
        $this->assertNotEmpty($handler->getParams()->getParamsData());
34
        $handler->getParams()->offsetUnset('mno');
35
        $vars = new SingleVariable($handler->getParams());
36
        $vars->setVariableName('poiu')->setVariableValue('ztrewq');
37
        $this->assertEquals('/abc/def//?ghi=jkl&stu=vwx&poiu=ztrewq', $handler->getAddress());
38
    }
39
}
40