Skip to content

Commit d8fde20

Browse files
authored
Upgrade "php-mock/php-mock-phpunit" dev package (#78)
1 parent 1dcf32d commit d8fde20

File tree

4 files changed

+89
-89
lines changed

4 files changed

+89
-89
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"ergebnis/phpunit-slow-test-detector": "^2.9",
5353
"friendsofphp/php-cs-fixer": "^3.0",
5454
"mikey179/vfsstream": "^1.6.11",
55-
"php-mock/php-mock-phpunit": "^2.1",
55+
"php-mock/php-mock-phpunit": "^2.12",
5656
"phpstan/extension-installer": "^1.1",
5757
"phpstan/phpstan": "^2.0",
5858
"phpstan/phpstan-deprecation-rules": "^2.0",
5959
"phpstan/phpstan-strict-rules": "^2.0",
6060
"phpunit/phpunit": "^9.5.25 || ^10.0 || ^11.0",
61-
"predis/predis": "^1.1.8",
61+
"predis/predis": "^1.1.8 || ^2.0",
6262
"spatie/async": "^1.5"
6363
},
6464
"suggest": {

tests/Mutex/DistributedMutexTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,21 @@ public function testAcquireWithMajority(int $count, int $available): void
234234
$mutex->synchronized(static function () {});
235235
}
236236

237+
/**
238+
* Provides test cases with enough.
239+
*
240+
* @return iterable<list<mixed>>
241+
*/
242+
public static function provideMajorityCases(): iterable
243+
{
244+
yield [1, 1];
245+
yield [2, 2];
246+
yield [3, 2];
247+
yield [3, 3];
248+
yield [4, 3];
249+
yield [5, 3];
250+
}
251+
237252
/**
238253
* Tests releasing fails because too few servers are available.
239254
*
@@ -312,21 +327,6 @@ public static function provideMinorityCases(): iterable
312327
yield [6, 3];
313328
}
314329

315-
/**
316-
* Provides test cases with enough.
317-
*
318-
* @return iterable<list<mixed>>
319-
*/
320-
public static function provideMajorityCases(): iterable
321-
{
322-
yield [1, 1];
323-
yield [2, 2];
324-
yield [3, 2];
325-
yield [3, 3];
326-
yield [4, 3];
327-
yield [5, 3];
328-
}
329-
330330
public function testAcquireMutexLogger(): void
331331
{
332332
$mutex = $this->createDistributedMutexMock(3);

tests/Mutex/MutexTest.php

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,60 @@ public static function setUpBeforeClass(): void
4040
vfsStream::setup('test');
4141
}
4242

43+
/**
44+
* Tests synchronized() executes the code and returns its result.
45+
*
46+
* @param \Closure(): Mutex $mutexFactory
47+
*
48+
* @dataProvider provideMutexFactoriesCases
49+
*/
50+
#[DataProvider('provideMutexFactoriesCases')]
51+
public function testSynchronizedDelegates(\Closure $mutexFactory): void
52+
{
53+
$mutex = $mutexFactory();
54+
$result = $mutex->synchronized(static function () {
55+
return 'test';
56+
});
57+
self::assertSame('test', $result);
58+
}
59+
60+
/**
61+
* Tests that synchronized() released the lock.
62+
*
63+
* @param \Closure(): Mutex $mutexFactory
64+
*
65+
* @doesNotPerformAssertions
66+
*
67+
* @dataProvider provideMutexFactoriesCases
68+
*/
69+
#[DoesNotPerformAssertions]
70+
#[DataProvider('provideMutexFactoriesCases')]
71+
public function testRelease(\Closure $mutexFactory): void
72+
{
73+
$mutex = $mutexFactory();
74+
$mutex->synchronized(static function () {});
75+
76+
$mutex->synchronized(static function () {});
77+
}
78+
79+
/**
80+
* Tests synchronized() rethrows the exception of the code.
81+
*
82+
* @param \Closure(): Mutex $mutexFactory
83+
*
84+
* @dataProvider provideMutexFactoriesCases
85+
*/
86+
#[DataProvider('provideMutexFactoriesCases')]
87+
public function testSynchronizedPassesExceptionThrough(\Closure $mutexFactory): void
88+
{
89+
$mutex = $mutexFactory();
90+
91+
$this->expectException(\DomainException::class);
92+
$mutex->synchronized(static function () {
93+
throw new \DomainException();
94+
});
95+
}
96+
4397
/**
4498
* Provides Mutex factories.
4599
*
@@ -188,58 +242,4 @@ static function ($uri) {
188242
}];
189243
}
190244
}
191-
192-
/**
193-
* Tests synchronized() executes the code and returns its result.
194-
*
195-
* @param \Closure(): Mutex $mutexFactory
196-
*
197-
* @dataProvider provideMutexFactoriesCases
198-
*/
199-
#[DataProvider('provideMutexFactoriesCases')]
200-
public function testSynchronizedDelegates(\Closure $mutexFactory): void
201-
{
202-
$mutex = $mutexFactory();
203-
$result = $mutex->synchronized(static function () {
204-
return 'test';
205-
});
206-
self::assertSame('test', $result);
207-
}
208-
209-
/**
210-
* Tests that synchronized() released the lock.
211-
*
212-
* @param \Closure(): Mutex $mutexFactory
213-
*
214-
* @doesNotPerformAssertions
215-
*
216-
* @dataProvider provideMutexFactoriesCases
217-
*/
218-
#[DoesNotPerformAssertions]
219-
#[DataProvider('provideMutexFactoriesCases')]
220-
public function testRelease(\Closure $mutexFactory): void
221-
{
222-
$mutex = $mutexFactory();
223-
$mutex->synchronized(static function () {});
224-
225-
$mutex->synchronized(static function () {});
226-
}
227-
228-
/**
229-
* Tests synchronized() rethrows the exception of the code.
230-
*
231-
* @param \Closure(): Mutex $mutexFactory
232-
*
233-
* @dataProvider provideMutexFactoriesCases
234-
*/
235-
#[DataProvider('provideMutexFactoriesCases')]
236-
public function testSynchronizedPassesExceptionThrough(\Closure $mutexFactory): void
237-
{
238-
$mutex = $mutexFactory();
239-
240-
$this->expectException(\DomainException::class);
241-
$mutex->synchronized(static function () {
242-
throw new \DomainException();
243-
});
244-
}
245245
}

tests/Mutex/RedisMutexTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,6 @@ public function testSerializersAndCompressors(int $serializer, int $compressor):
258258
}));
259259
}
260260

261-
public function testResistantToPartialClusterFailuresForAcquiringLock(): void
262-
{
263-
$this->closeMinorityConnections();
264-
265-
self::assertSame('test', $this->mutex->synchronized(static function () {
266-
return 'test';
267-
}));
268-
}
269-
270-
public function testResistantToPartialClusterFailuresForReleasingLock(): void
271-
{
272-
self::assertNull($this->mutex->synchronized(function () { // @phpstan-ignore staticMethod.alreadyNarrowedType
273-
$this->closeMinorityConnections();
274-
275-
return null;
276-
}));
277-
}
278-
279261
/**
280262
* @return iterable<list<mixed>>
281263
*/
@@ -313,4 +295,22 @@ public static function provideSerializersAndCompressorsCases(): iterable
313295
}
314296
}
315297
}
298+
299+
public function testResistantToPartialClusterFailuresForAcquiringLock(): void
300+
{
301+
$this->closeMinorityConnections();
302+
303+
self::assertSame('test', $this->mutex->synchronized(static function () {
304+
return 'test';
305+
}));
306+
}
307+
308+
public function testResistantToPartialClusterFailuresForReleasingLock(): void
309+
{
310+
self::assertNull($this->mutex->synchronized(function () { // @phpstan-ignore staticMethod.alreadyNarrowedType
311+
$this->closeMinorityConnections();
312+
313+
return null;
314+
}));
315+
}
316316
}

0 commit comments

Comments
 (0)