1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AsyncPHP\Doorman\Tests\Rule; |
4
|
|
|
|
5
|
|
|
use AsyncPHP\Doorman\Rule\InMemoryRule; |
6
|
|
|
use AsyncPHP\Doorman\Tests\Test; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers AsyncPHP\Doorman\Rule\InMemoryRule |
10
|
|
|
*/ |
11
|
|
|
class InMemoryRuleTest extends Test |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var InMemoryRule |
15
|
|
|
*/ |
16
|
|
|
protected $rule; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @inheritdoc |
20
|
|
|
*/ |
21
|
|
|
public function setUp() |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
|
25
|
|
|
$this->rule = new InMemoryRule(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @test |
30
|
|
|
* |
31
|
|
|
* @dataProvider gettersAndSettersProvider |
32
|
|
|
* |
33
|
|
|
* @param string $getter |
34
|
|
|
* @param string $setter |
35
|
|
|
* @param mixed $value |
36
|
|
|
*/ |
37
|
|
|
public function gettersAndSettersWork($getter, $setter, $value) |
38
|
|
|
{ |
39
|
|
|
$this->rule->$setter($value); |
40
|
|
|
|
41
|
|
|
$this->assertSame($value, $this->rule->$getter()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function gettersAndSettersProvider() |
48
|
|
|
{ |
49
|
|
|
return array( |
50
|
|
|
array("getProcesses", "setProcesses", 3), |
51
|
|
|
array("getHandler", "setHandler", "Three"), |
52
|
|
|
array("getMinimumProcessorUsage", "setMinimumProcessorUsage", 33.0), |
53
|
|
|
array("getMaximumProcessorUsage", "setMaximumProcessorUsage", 33.0), |
54
|
|
|
array("getMinimumMemoryUsage", "setMinimumMemoryUsage", 33.0), |
55
|
|
|
array("getMaximumMemoryUsage", "setMaximumMemoryUsage", 33.0), |
56
|
|
|
array("getMinimumSiblingProcessorUsage", "setMinimumSiblingProcessorUsage", 33.0), |
57
|
|
|
array("getMaximumSiblingProcessorUsage", "setMaximumSiblingProcessorUsage", 33.0), |
58
|
|
|
array("getMinimumSiblingMemoryUsage", "setMinimumSiblingMemoryUsage", 33.0), |
59
|
|
|
array("getMaximumSiblingMemoryUsage", "setMaximumSiblingMemoryUsage", 33.0), |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|