Issues (31)

php-tests/SimplifiedTests/CookieAdapterTest.php (6 issues)

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