@@ -44,9 +44,12 @@ public function testCheckFailsAcquiresNoLock()
44
44
$ this ->checkedLocking ->setCheck (function () {
45
45
return false ;
46
46
});
47
- $ this ->checkedLocking ->then (function () {
47
+ $ result = $ this ->checkedLocking ->then (function () {
48
48
$ this ->fail ();
49
49
});
50
+
51
+ // Failed check should return false.
52
+ $ this ->assertFalse ($ result );
50
53
}
51
54
52
55
/**
@@ -63,23 +66,31 @@ public function testLockedCheckAndExecution()
63
66
->method ("synchronized " )
64
67
->willReturnCallback (function (callable $ block ) use (&$ lock ) {
65
68
$ lock ++;
66
- call_user_func ($ block );
69
+ $ result = call_user_func ($ block );
67
70
$ lock ++;
71
+
72
+ return $ result ;
68
73
});
69
74
70
75
$ this ->checkedLocking ->setCheck (function () use (&$ lock , &$ check ) {
71
76
if ($ check == 1 ) {
72
77
$ this ->assertEquals (1 , $ lock );
73
78
}
74
79
$ check ++;
80
+
75
81
return true ;
76
82
});
77
83
78
- $ this ->checkedLocking ->then (function () use (&$ lock ) {
84
+ $ result = $ this ->checkedLocking ->then (function () use (&$ lock ) {
79
85
$ this ->assertEquals (1 , $ lock );
86
+
87
+ return 'test ' ;
80
88
});
81
89
82
90
$ this ->assertEquals (2 , $ check );
91
+
92
+ // Synchronized code should return a test string.
93
+ $ this ->assertEquals ('test ' , $ result );
83
94
}
84
95
85
96
/**
@@ -98,9 +109,12 @@ public function testCodeNotExecuted(callable $check)
98
109
});
99
110
100
111
$ this ->checkedLocking ->setCheck ($ check );
101
- $ this ->checkedLocking ->then (function () {
112
+ $ result = $ this ->checkedLocking ->then (function () {
102
113
$ this ->fail ();
103
114
});
115
+
116
+ // Each failed check should return false.
117
+ $ this ->assertFalse ($ result );
104
118
}
105
119
106
120
/**
@@ -142,9 +156,13 @@ public function testCodeExecuted()
142
156
});
143
157
144
158
$ executed = false ;
145
- $ this ->checkedLocking ->then (function () use (&$ executed ) {
159
+ $ result = $ this ->checkedLocking ->then (function () use (&$ executed ) {
146
160
$ executed = true ;
161
+
162
+ return 'test ' ;
147
163
});
164
+
148
165
$ this ->assertTrue ($ executed );
166
+ $ this ->assertEquals ('test ' , $ result );
149
167
}
150
168
}
0 commit comments