Passed
Push — master ( de4ed9...5f6eee )
by Petr
10:41
created

CookieAdapterTest::testPass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.6666
1
<?php
2
3
namespace SimplifiedTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_input\InputException;
8
use kalanis\kw_input\Simplified;
9
10
11
class CookieAdapterTest extends CommonTestClass
12
{
13
    public function testPass(): void
14
    {
15
        Simplified\CookieAdapter::init('', '', null, false, false, false);
16
        $data = new Simplified\CookieAdapter();
17
        $this->assertInstanceOf(\ArrayAccess::class, $data);
18
19
        $data->foz = 'wuz';
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __set, consider adding a @property annotation.
Loading history...
20
        $this->assertTrue(isset($data->foz));
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __get, consider adding a @property annotation.
Loading history...
21
        $this->assertEquals('wuz', $data->foz);
22
        unset($data->foz);
23
24
        $data['ugg'] = 'huu';
25
        $this->assertTrue(isset($data['ugg']));
26
        $this->assertEquals('huu', $data['ugg']);
27
        unset($data['ugg']);
28
29
        $nullKey = 'bnm' . chr(0) . 'lkj';
30
        $data[$nullKey] = 'thd';
31
        $this->assertTrue(isset($data[$nullKey]));
32
        $this->assertTrue(isset($data['bnmlkj']));
33
        $this->assertEquals('thd', $data[$nullKey]);
34
        $this->assertEquals('thd', $data['bnmlkj']);
35
        unset($data[$nullKey]);
36
    }
37
38
    public function testDie1(): void
39
    {
40
        Simplified\CookieAdapter::init('', '', null, false, false, false, true);
41
        $data = new Simplified\CookieAdapter();
42
        $this->expectException(InputException::class);
43
        $data->foz = 'wuz';
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __set, consider adding a @property annotation.
Loading history...
44
    }
45
46
    public function testDie2(): void
47
    {
48
        Simplified\CookieAdapter::init('', '', null, false, false, false, true);
49
        $data = new Simplified\CookieAdapter();
50
        $this->expectException(InputException::class);
51
        unset($data->foz);
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __get, consider adding a @property annotation.
Loading history...
52
    }
53
54
    public function testIterator(): void
55
    {
56
        Simplified\CookieAdapter::init('', '', null, false, false, false);
57
        $data = new Simplified\CookieAdapter();
58
59
        $this->assertEmpty(iterator_to_array($data->getIterator()));
60
        $data->foz = 'wuz';
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __set, consider adding a @property annotation.
Loading history...
61
        $this->assertNotEmpty(iterator_to_array($data->getIterator()));
62
        unset($data->foz);
0 ignored issues
show
Bug Best Practice introduced by
The property foz does not exist on kalanis\kw_input\Simplified\CookieAdapter. Since you implemented __get, consider adding a @property annotation.
Loading history...
63
        $this->assertEmpty(iterator_to_array($data->getIterator()));
64
    }
65
}
66