1
+ <?php
2
+
3
+
4
+ use EasySwoole \Component \Process \Config ;
5
+ use EasySwoole \Component \Tests \Lib \TestProcess ;
6
+ use PHPUnit \Framework \TestCase ;
7
+ use EasySwoole \Component \Process \Manager ;
8
+
9
+ class ProcessManagerTest extends TestCase
10
+ {
11
+
12
+
13
+ public function testGetProcessByPid ()
14
+ {
15
+ $ config = new Config ();
16
+ $ process = new TestProcess ($ config );
17
+ Manager::getInstance ()->addProcess ($ process );
18
+
19
+ $ this ->assertEquals (null , Manager::getInstance ()->getProcessByPid (0 ));
20
+ }
21
+
22
+ public function testGetProcessByName ()
23
+ {
24
+ $ process = new TestProcess ();
25
+ Manager::getInstance ()->addProcess ($ process );
26
+ $ this ->assertEmpty (Manager::getInstance ()->getProcessByName ('test ' ));
27
+
28
+
29
+ $ config = new Config ();
30
+ $ process = new TestProcess ($ config );
31
+ $ config ->setProcessName ('test ' );
32
+ Manager::getInstance ()->addProcess ($ process );
33
+ $ this ->assertEquals (1 , count (Manager::getInstance ()->getProcessByName ('test ' )));
34
+ }
35
+
36
+ public function testGetProcessByGroup ()
37
+ {
38
+ $ process = new TestProcess ();
39
+ Manager::getInstance ()->addProcess ($ process );
40
+ $ this ->assertEmpty (Manager::getInstance ()->getProcessByGroup ('test ' ));
41
+
42
+
43
+ $ config = new Config ();
44
+ $ process = new TestProcess ($ config );
45
+ $ config ->setProcessGroup ('test ' );
46
+ Manager::getInstance ()->addProcess ($ process );
47
+ $ this ->assertEquals (1 , count (Manager::getInstance ()->getProcessByGroup ('test ' )));
48
+ }
49
+ }
0 commit comments