QueryTest::testGetSetQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Purl\Test;
6
7
use PHPUnit\Framework\TestCase;
8
use Purl\Query;
9
10
class QueryTest extends TestCase
11
{
12
    public function testConstruct() : void
13
    {
14
        $query = new Query('param=value');
15
        $this->assertEquals('param=value', $query->getQuery());
16
    }
17
18
    public function testGetSetQuery() : void
19
    {
20
        $query = new Query();
21
        $this->assertEquals('', $query->getQuery());
22
        $query->setQuery('param1=value1&param2=value2');
23
        $this->assertEquals('param1=value1&param2=value2', $query->getQuery());
24
    }
25
26
    public function testToString() : void
27
    {
28
        $query = new Query('param1=value1&param2=value2');
29
        $this->assertEquals('param1=value1&param2=value2', (string) $query);
30
    }
31
32
    public function testGetSetData() : void
33
    {
34
        $query = new Query('param1=value1&param2=value2');
35
        $this->assertEquals(['param1' => 'value1', 'param2' => 'value2'], $query->getData());
36
        $query->setData(['param' => 'value']);
37
        $this->assertEquals('param=value', $query->getQuery());
38
    }
39
}
40