@@ -44,9 +44,12 @@ public function testCheckFailsAcquiresNoLock()
4444 $ this ->checkedLocking ->setCheck (function () {
4545 return false ;
4646 });
47- $ this ->checkedLocking ->then (function () {
47+ $ result = $ this ->checkedLocking ->then (function () {
4848 $ this ->fail ();
4949 });
50+
51+ // Failed check should return false.
52+ $ this ->assertFalse ($ result );
5053 }
5154
5255 /**
@@ -63,23 +66,31 @@ public function testLockedCheckAndExecution()
6366 ->method ("synchronized " )
6467 ->willReturnCallback (function (callable $ block ) use (&$ lock ) {
6568 $ lock ++;
66- call_user_func ($ block );
69+ $ result = call_user_func ($ block );
6770 $ lock ++;
71+
72+ return $ result ;
6873 });
6974
7075 $ this ->checkedLocking ->setCheck (function () use (&$ lock , &$ check ) {
7176 if ($ check == 1 ) {
7277 $ this ->assertEquals (1 , $ lock );
7378 }
7479 $ check ++;
80+
7581 return true ;
7682 });
7783
78- $ this ->checkedLocking ->then (function () use (&$ lock ) {
84+ $ result = $ this ->checkedLocking ->then (function () use (&$ lock ) {
7985 $ this ->assertEquals (1 , $ lock );
86+
87+ return 'test ' ;
8088 });
8189
8290 $ this ->assertEquals (2 , $ check );
91+
92+ // Synchronized code should return a test string.
93+ $ this ->assertEquals ('test ' , $ result );
8394 }
8495
8596 /**
@@ -98,9 +109,12 @@ public function testCodeNotExecuted(callable $check)
98109 });
99110
100111 $ this ->checkedLocking ->setCheck ($ check );
101- $ this ->checkedLocking ->then (function () {
112+ $ result = $ this ->checkedLocking ->then (function () {
102113 $ this ->fail ();
103114 });
115+
116+ // Each failed check should return false.
117+ $ this ->assertFalse ($ result );
104118 }
105119
106120 /**
@@ -142,9 +156,13 @@ public function testCodeExecuted()
142156 });
143157
144158 $ executed = false ;
145- $ this ->checkedLocking ->then (function () use (&$ executed ) {
159+ $ result = $ this ->checkedLocking ->then (function () use (&$ executed ) {
146160 $ executed = true ;
161+
162+ return 'test ' ;
147163 });
164+
148165 $ this ->assertTrue ($ executed );
166+ $ this ->assertEquals ('test ' , $ result );
149167 }
150168}
0 commit comments