File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,8 @@ protected function unlock()
8080 $ elapsed = microtime (true ) - $ this ->acquired ;
8181 if ($ elapsed >= $ this ->timeout ) {
8282 $ message = sprintf (
83- "The code executed for %.2f seconds. But the timeout is %d " .
84- "seconds. The last %.2f seconds were executed outside the lock. " ,
83+ "The code executed for %.2F seconds. But the timeout is %d " .
84+ "seconds. The last %.2F seconds were executed outside the lock. " ,
8585 $ elapsed ,
8686 $ this ->timeout ,
8787 $ elapsed - $ this ->timeout
Original file line number Diff line number Diff line change 22
33namespace malkusch \lock \mutex ;
44
5+ use malkusch \lock \exception \ExecutionOutsideLockException ;
56use malkusch \lock \exception \LockAcquireException ;
6- use phpmock \phpunit \PHPMock ;
77use phpmock \environment \SleepEnvironmentBuilder ;
8+ use phpmock \phpunit \PHPMock ;
89
910/**
1011 * Tests for SpinlockMutex.
@@ -68,14 +69,19 @@ public function testAcquireTimesOut()
6869 * Tests executing code which exceeds the timeout fails.
6970 *
7071 * @test
71- * @expectedException malkusch\lock\exception\ExecutionOutsideLockException
7272 */
7373 public function testExecuteTooLong ()
7474 {
7575 $ mutex = $ this ->getMockForAbstractClass (SpinlockMutex::class, ["test " , 1 ]);
7676 $ mutex ->expects ($ this ->any ())->method ("acquire " )->willReturn (true );
7777 $ mutex ->expects ($ this ->any ())->method ("release " )->willReturn (true );
7878
79+ $ this ->expectException (ExecutionOutsideLockException::class);
80+ $ this ->expectExceptionMessageRegExp (
81+ '/The code executed for \d+\.\d+ seconds. But the timeout is 1 ' .
82+ 'seconds. The last \d+\.\d+ seconds were executed outside the lock./ '
83+ );
84+
7985 $ mutex ->synchronized (function () {
8086 sleep (1 );
8187 });
You can’t perform that action at this time.
0 commit comments