8
8
use Workbunny \Tests \TestCase ;
9
9
use Workbunny \WebmanCoroutine \Utils \WaitGroup \Handlers \SwowWaitGroup ;
10
10
11
- /**
12
- * @runTestsInSeparateProcesses
13
- */
14
11
class SwowWaitGroupTest extends TestCase
15
12
{
16
13
protected int $ _count = 0 ;
@@ -25,13 +22,9 @@ protected function tearDown(): void
25
22
public function testAdd ()
26
23
{
27
24
$ swowMock = Mockery::mock ('alias:Swow\Sync\WaitGroup ' );
28
- $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function () {
25
+ $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function ($ delta ) {
29
26
// 模拟增加计数
30
- $ this ->_count ++;
31
- });
32
- $ swowMock ->shouldReceive ('count ' )->with (1 )->andReturnUsing (function () {
33
- // 模拟增加计数
34
- return $ this ->_count ;
27
+ $ this ->_count += $ delta ;
35
28
});
36
29
37
30
$ wg = new SwowWaitGroup ();
@@ -47,18 +40,14 @@ public function testAdd()
47
40
public function testDone ()
48
41
{
49
42
$ swowMock = Mockery::mock ('alias:Swow\Sync\WaitGroup ' );
50
- $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function () {
43
+ $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function ($ delta ) {
51
44
// 模拟增加计数
52
- $ this ->_count ++ ;
45
+ $ this ->_count += $ delta ;
53
46
});
54
47
$ swowMock ->shouldReceive ('done ' )->andReturnUsing (function () {
55
48
// 模拟减少计数
56
49
$ this ->_count --;
57
50
});
58
- $ swowMock ->shouldReceive ('count ' )->with (1 )->andReturnUsing (function () {
59
- // 模拟增加计数
60
- return $ this ->_count ;
61
- });
62
51
63
52
$ wg = new SwowWaitGroup ();
64
53
$ reflection = new \ReflectionClass ($ wg );
@@ -74,13 +63,9 @@ public function testDone()
74
63
public function testCount ()
75
64
{
76
65
$ swowMock = Mockery::mock ('alias:Swow\Sync\WaitGroup ' );
77
- $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function () {
66
+ $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function ($ delta ) {
78
67
// 模拟增加计数
79
- $ this ->_count ++;
80
- });
81
- $ swowMock ->shouldReceive ('count ' )->with (1 )->andReturnUsing (function () {
82
- // 模拟增加计数
83
- return $ this ->_count ;
68
+ $ this ->_count += $ delta ;
84
69
});
85
70
$ wg = new SwowWaitGroup ();
86
71
$ reflection = new \ReflectionClass ($ wg );
@@ -96,18 +81,14 @@ public function testCount()
96
81
public function testWait ()
97
82
{
98
83
$ swowMock = Mockery::mock ('alias:Swow\Sync\WaitGroup ' );
99
- $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function () {
84
+ $ swowMock ->shouldReceive ('add ' )->with (1 )->andReturnUsing (function ($ delta ) {
100
85
// 模拟增加计数
101
- $ this ->_count ++ ;
86
+ $ this ->_count += $ delta ;
102
87
});
103
88
$ swowMock ->shouldReceive ('done ' )->andReturnUsing (function () {
104
89
// 模拟减少计数
105
90
$ this ->_count --;
106
91
});
107
- $ swowMock ->shouldReceive ('count ' )->with (1 )->andReturnUsing (function () {
108
- // 模拟增加计数
109
- return $ this ->_count ;
110
- });
111
92
$ swowMock ->shouldReceive ('wait ' )->with (-1 )->andReturnNull ();
112
93
113
94
$ wg = new SwowWaitGroup ();
0 commit comments