EntryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 29
dl 0
loc 80
rs 10
c 2
b 0
f 1
wmc 2

10 Methods

Rating   Name   Duplication   Size   Complexity  
A relationProvider() 0 6 1
A testRelations() 0 5 1
A keyProvider() 0 4 1
A testEntry() 0 6 1
A testKeys() 0 5 1
A testValues() 0 5 1
A hp$0 ➔ getAnonClass() 0 6 1
A hp$0 ➔ __toString() 0 3 1
getAnonClass() 0 6 ?
A valueProvider() 0 9 1
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_filter\FilterEntry;
8
use kalanis\kw_filter\Interfaces\IFilterEntry;
9
10
11
class EntryTest extends CommonTestClass
12
{
13
    public function testEntry(): void
14
    {
15
        $entry = new FilterEntry();
16
        $this->assertEmpty($entry->getKey());
17
        $this->assertEmpty($entry->getValue());
18
        $this->assertEquals(IFilterEntry::RELATION_EQUAL, $entry->getRelation());
19
    }
20
21
    /**
22
     * @param string $keys
23
     * @param string $expected
24
     * @dataProvider keyProvider
25
     */
26
    public function testKeys(string $keys, string $expected): void
27
    {
28
        $entry = new FilterEntry();
29
        $entry->setKey($keys);
30
        $this->assertEquals($expected, $entry->getKey());
31
    }
32
33
    public function keyProvider(): array
34
    {
35
        return [
36
            ['any', 'any'],
37
        ];
38
    }
39
40
    /**
41
     * @param mixed $values
42
     * @param string $expected
43
     * @dataProvider valueProvider
44
     */
45
    public function testValues($values, string $expected): void
46
    {
47
        $entry = new FilterEntry();
48
        $entry->setValue($values);
49
        $this->assertEquals($expected, $entry->getValue());
50
    }
51
52
    public function valueProvider(): array
53
    {
54
        return [
55
            ['poi', 'poi'],
56
            [['dggh', 'sdfhg'], 'dggh'],
57
            [[1353, 'ysdg'], '1353'],
58
            [false, ''],
59
            [true, '1'],
60
            [$this->getAnonClass(), 'fbjgf'],
61
        ];
62
    }
63
64
    /**
65
     * @param string $value
66
     * @param string $expected
67
     * @dataProvider relationProvider
68
     */
69
    public function testRelations(string $value, string $expected): void
70
    {
71
        $entry = new FilterEntry();
72
        $entry->setRelation($value);
73
        $this->assertEquals($expected, $entry->getRelation());
74
    }
75
76
    public function relationProvider(): array
77
    {
78
        return [
79
            [IFilterEntry::RELATION_EQUAL, IFilterEntry::RELATION_EQUAL],
80
            [IFilterEntry::RELATION_MORE, IFilterEntry::RELATION_MORE],
81
            ['bad', IFilterEntry::RELATION_EQUAL],
82
        ];
83
    }
84
85
    protected function getAnonClass(): object
86
    {
87
        return new class {
88
            public function __toString()
89
            {
90
                return 'fbjgf';
91
            }
92
        };
93
    }
94
}
95