Passed
Push — master ( e6a12d...210e25 )
by Petr
08:06
created

CommonTestClass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 4
1
<?php
2
3
use kalanis\kw_rules\Rules;
4
use kalanis\kw_rules\TRules;
5
use kalanis\kw_rules\Interfaces;
6
use PHPUnit\Framework\TestCase;
7
8
9
class CommonTestClass extends TestCase
10
{
11
    public function equalsProvider()
12
    {
13
        return [
14
            ['abc', 'def', 'def', true],
15
            ['foo', 'bar', 'baz', false],
16
        ];
17
    }
18
19
    protected function getMockImage()
20
    {
21
        return MockFile::init('foo', 'test1.gif', 'text/plain',
22
            realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, 'data', 'tester.gif'])),
23
            55, UPLOAD_ERR_OK );
24
    }
25
26
    protected function getMockFile()
27
    {
28
        return MockFile::init('foo', 'text1.txt', 'text/plain',
29
            realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, 'data', 'testing.1.txt'])),
30
            13, UPLOAD_ERR_OK );
31
    }
32
33
    protected function getMockNoFile()
34
    {
35
        return MockFile::init('foo', 'text0.txt', 'text/plain',
36
            '', 26, UPLOAD_ERR_NO_FILE );
37
    }
38
}
39
40
41
class MockEntry implements Interfaces\IValidate
42
{
43
    use TRules;
44
45
    protected $mockKey = '';
46
    protected $mockValue = '';
47
48
    protected function whichFactory(): Interfaces\IRuleFactory
49
    {
50
        return new Rules\Factory();
51
    }
52
53
    public static function init(string $key, $value): self
54
    {
55
        $lib = new static();
56
        return $lib->setData($key, $value);
57
    }
58
59
    public function setData(string $key, $value): self
60
    {
61
        $this->mockKey = $key;
62
        $this->mockValue = $value;
63
        return $this;
64
    }
65
66
    public function getKey(): string
67
    {
68
        return $this->mockKey;
69
    }
70
71
    public function getValue()
72
    {
73
        return $this->mockValue;
74
    }
75
}
76
77
78
class MockFile implements Interfaces\IValidateFile
79
{
80
    use TRules;
81
82
    protected $mockKey = '';
83
    protected $mockValue = '';
84
    protected $mockMime = '';
85
    protected $mockName = '';
86
    protected $mockSize = 0;
87
    protected $mockError = 0;
88
89
    protected function whichFactory(): Interfaces\IRuleFactory
90
    {
91
        return new Rules\File\Factory();
92
    }
93
94
    public static function init(string $key, string $value, string $mime, string $name, int $size, int $error): self
95
    {
96
        $lib = new static();
97
        return $lib->setData($key, $value, $mime, $name, $size, $error);
98
    }
99
100
    public function setData(string $key, $value, string $mime, string $name, int $size, int $error): self
101
    {
102
        $this->mockKey = $key;
103
        $this->mockValue = $value;
104
        $this->mockMime = $mime;
105
        $this->mockName = $name;
106
        $this->mockSize = $size;
107
        $this->mockError = $error;
108
        return $this;
109
    }
110
111
    public function getKey(): string
112
    {
113
        return $this->mockKey;
114
    }
115
116
    public function getValue()
117
    {
118
        return $this->mockValue;
119
    }
120
121
    public function getMimeType(): string
122
    {
123
        return $this->mockMime;
124
    }
125
126
    public function getTempName(): string
127
    {
128
        return $this->mockName;
129
    }
130
131
    public function getError(): int
132
    {
133
        return $this->mockError;
134
    }
135
136
    public function getSize(): int
137
    {
138
        return $this->mockSize;
139
    }
140
}
141