|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AsyncPHP\Doorman\Tests\Profile; |
|
4
|
|
|
|
|
5
|
|
|
use AsyncPHP\Doorman\Profile\InMemoryProfile; |
|
6
|
|
|
use AsyncPHP\Doorman\Task\ProcessCallbackTask; |
|
7
|
|
|
use AsyncPHP\Doorman\Tests\Test; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @covers AsyncPHP\Doorman\Profile\InMemoryProfile |
|
11
|
|
|
*/ |
|
12
|
|
|
class InMemoryProfileTest extends Test |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var InMemoryProfile |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $rule; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @inheritdoc |
|
21
|
|
|
*/ |
|
22
|
|
|
public function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
parent::setUp(); |
|
25
|
|
|
|
|
26
|
|
|
$this->rule = new InMemoryProfile(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @test |
|
31
|
|
|
* |
|
32
|
|
|
* @dataProvider gettersAndSettersProvider |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $getter |
|
35
|
|
|
* @param string $setter |
|
36
|
|
|
* @param mixed $value |
|
37
|
|
|
*/ |
|
38
|
|
|
public function gettersAndSettersWork($getter, $setter, $value) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->rule->$setter($value); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertSame($value, $this->rule->$getter()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return array |
|
47
|
|
|
*/ |
|
48
|
|
|
public function gettersAndSettersProvider() |
|
49
|
|
|
{ |
|
50
|
|
|
$task = new ProcessCallbackTask(function () { |
|
51
|
|
|
return; |
|
52
|
|
|
}); |
|
53
|
|
|
|
|
54
|
|
|
return array( |
|
55
|
|
|
array("getProcesses", "setProcesses", array($task)), |
|
56
|
|
|
array("getProcessorLoad", "setProcessorLoad", 33.0), |
|
57
|
|
|
array("getMemoryLoad", "setMemoryLoad", 33.0), |
|
58
|
|
|
array("getSiblingProcesses", "setSiblingProcesses", array($task)), |
|
59
|
|
|
array("getSiblingProcessorLoad", "setSiblingProcessorLoad", 33.0), |
|
60
|
|
|
array("getSiblingMemoryLoad", "setSiblingMemoryLoad", 33.0), |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|