8
8
use Malkusch \Lock \Exception \LockAcquireException ;
9
9
use Malkusch \Lock \Exception \LockReleaseException ;
10
10
use Malkusch \Lock \Exception \TimeoutException ;
11
- use Malkusch \Lock \Mutex \SpinlockMutex ;
11
+ use Malkusch \Lock \Mutex \AbstractSpinlockMutex ;
12
12
use phpmock \environment \SleepEnvironmentBuilder ;
13
13
use phpmock \MockEnabledException ;
14
14
use phpmock \phpunit \PHPMock ;
15
15
use PHPUnit \Framework \MockObject \MockObject ;
16
16
use PHPUnit \Framework \TestCase ;
17
17
18
- class SpinlockMutexTest extends TestCase
18
+ class AbstractSpinlockMutexTest extends TestCase
19
19
{
20
20
use PHPMock;
21
21
@@ -39,11 +39,11 @@ protected function setUp(): void
39
39
}
40
40
41
41
/**
42
- * @return SpinlockMutex &MockObject
42
+ * @return AbstractSpinlockMutex &MockObject
43
43
*/
44
- private function createSpinlockMutexMock (float $ timeout = 3 ): SpinlockMutex
44
+ private function createAbstractSpinlockMutexMock (float $ timeout = 3 ): AbstractSpinlockMutex
45
45
{
46
- return $ this ->getMockBuilder (SpinlockMutex ::class)
46
+ return $ this ->getMockBuilder (AbstractSpinlockMutex ::class)
47
47
->setConstructorArgs (['test ' , $ timeout ])
48
48
->onlyMethods (['acquire ' , 'release ' ])
49
49
->getMock ();
@@ -56,7 +56,7 @@ public function testFailAcquireLock(): void
56
56
{
57
57
$ this ->expectException (LockAcquireException::class);
58
58
59
- $ mutex = $ this ->createSpinlockMutexMock ();
59
+ $ mutex = $ this ->createAbstractSpinlockMutexMock ();
60
60
$ mutex ->expects (self ::any ())
61
61
->method ('acquire ' )
62
62
->willThrowException (new LockAcquireException ());
@@ -74,7 +74,7 @@ public function testAcquireTimesOut(): void
74
74
$ this ->expectException (TimeoutException::class);
75
75
$ this ->expectExceptionMessage ('Timeout of 3.0 seconds exceeded ' );
76
76
77
- $ mutex = $ this ->createSpinlockMutexMock ();
77
+ $ mutex = $ this ->createAbstractSpinlockMutexMock ();
78
78
$ mutex ->expects (self ::atLeastOnce ())
79
79
->method ('acquire ' )
80
80
->willReturn (false );
@@ -89,7 +89,7 @@ public function testAcquireTimesOut(): void
89
89
*/
90
90
public function testExecuteTooLong (): void
91
91
{
92
- $ mutex = $ this ->createSpinlockMutexMock (0.5 );
92
+ $ mutex = $ this ->createAbstractSpinlockMutexMock (0.5 );
93
93
$ mutex ->expects (self ::any ())
94
94
->method ('acquire ' )
95
95
->willReturn (true );
@@ -114,7 +114,7 @@ public function testExecuteTooLong(): void
114
114
*/
115
115
public function testExecuteBarelySucceeds (): void
116
116
{
117
- $ mutex = $ this ->createSpinlockMutexMock (0.5 );
117
+ $ mutex = $ this ->createAbstractSpinlockMutexMock (0.5 );
118
118
$ mutex ->expects (self ::any ())->method ('acquire ' )->willReturn (true );
119
119
$ mutex ->expects (self ::once ())->method ('release ' )->willReturn (true );
120
120
@@ -130,7 +130,7 @@ public function testFailReleasingLock(): void
130
130
{
131
131
$ this ->expectException (LockReleaseException::class);
132
132
133
- $ mutex = $ this ->createSpinlockMutexMock ();
133
+ $ mutex = $ this ->createAbstractSpinlockMutexMock ();
134
134
$ mutex ->expects (self ::any ())->method ('acquire ' )->willReturn (true );
135
135
$ mutex ->expects (self ::any ())->method ('release ' )->willReturn (false );
136
136
@@ -142,7 +142,7 @@ public function testFailReleasingLock(): void
142
142
*/
143
143
public function testExecuteTimeoutLeavesOneSecondForKeyToExpire (): void
144
144
{
145
- $ mutex = $ this ->createSpinlockMutexMock (0.2 );
145
+ $ mutex = $ this ->createAbstractSpinlockMutexMock (0.2 );
146
146
$ mutex ->expects (self ::once ())
147
147
->method ('acquire ' )
148
148
->with (self ::anything (), 1.2 )
0 commit comments