Skip to content

Commit 457cc77

Browse files
committed
Laravel 11 support
1 parent 0e3f65e commit 457cc77

7 files changed

+69
-82
lines changed

.github/workflows/tests.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
php: [8.1, 8.2]
11+
php: [8.2, 8.3, 8.4]
1212
stability: [prefer-lowest, prefer-stable]
1313

1414
name: PHP ${{ matrix.php }} / ${{ matrix.stability }}
1515

1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2
@@ -41,6 +41,8 @@ jobs:
4141
run: vendor/bin/phpunit --colors=always --coverage-clover ./build/logs/clover.xml
4242

4343
- name: Code coverage
44-
uses: codecov/codecov-action@v1
44+
uses: codecov/codecov-action@v3
4545
with:
46-
file: ./build/logs/clover.xml
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
files: ./build/logs/clover.xml
48+
fail_ci_if_error: true

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Mutex for Laravel Console Commands.
1717

1818
| Laravel | Console Mutex |
1919
|---------|--------------------------------------------------------------------------|
20-
| 11.x | _[Support](https://buymeacoffee.com/dmitry.ivanov)_ |
20+
| 11.x | [11.x](https://github.com/dmitry-ivanov/laravel-console-mutex/tree/11.x) |
2121
| 10.x | [10.x](https://github.com/dmitry-ivanov/laravel-console-mutex/tree/10.x) |
2222
| 9.x | [9.x](https://github.com/dmitry-ivanov/laravel-console-mutex/tree/9.x) |
2323
| 8.x | [8.x](https://github.com/dmitry-ivanov/laravel-console-mutex/tree/8.x) |

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
"email": "[email protected]"
1313
}],
1414
"require": {
15-
"php": "^8.1",
15+
"php": "^8.2",
1616
"arvenil/ninja-mutex": "dev-master#82cbb2c",
17-
"illuminate/console": "^10.0",
18-
"illuminate/support": "^10.0"
17+
"illuminate/console": "^11.0",
18+
"illuminate/support": "^11.0"
1919
},
2020
"require-dev": {
2121
"ext-redis": "*",
2222
"ext-pdo_mysql": "*",
23-
"phpunit/phpunit": "^10.5",
24-
"mockery/mockery": "^1.5.1",
25-
"orchestra/testbench": "^8.0",
26-
"illuminated/testing-tools": "^10.0",
27-
"predis/predis": "^2.0.2"
23+
"phpunit/phpunit": "^11.3.6",
24+
"mockery/mockery": "^1.6.10",
25+
"orchestra/testbench": "^9.11.2",
26+
"illuminated/testing-tools": "^11.0",
27+
"predis/predis": "^2.3"
2828
},
2929
"autoload": {
3030
"psr-4": {

phpunit.xml.dist

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
3-
backupGlobals="false"
4-
backupStaticProperties="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
53
beStrictAboutTestsThatDoNotTestAnything="false"
64
beStrictAboutOutputDuringTests="true"
75
bootstrap="vendor/autoload.php"
8-
cacheDirectory=".phpunit.cache"
96
colors="true"
10-
processIsolation="false"
11-
stopOnError="false"
12-
stopOnFailure="false"
7+
displayDetailsOnPhpunitDeprecations="true"
8+
displayDetailsOnTestsThatTriggerErrors="true"
9+
displayDetailsOnTestsThatTriggerNotices="true"
10+
displayDetailsOnTestsThatTriggerWarnings="true"
1311
>
1412
<testsuites>
1513
<testsuite name="Laravel Console Mutex Test Suite">
16-
<directory suffix="Test.php">./tests</directory>
14+
<directory>./tests</directory>
1715
</testsuite>
1816
</testsuites>
1917

2018
<source>
2119
<include>
22-
<directory suffix=".php">./src</directory>
20+
<directory>./src</directory>
2321
</include>
2422
</source>
2523
</phpunit>

tests/MutexTest.php

+19-20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use NinjaMutex\Lock\MySQLPDOLock;
1414
use NinjaMutex\Lock\PhpRedisLock;
1515
use NinjaMutex\Lock\PredisRedisLock;
16+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
17+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
18+
use PHPUnit\Framework\Attributes\Test;
1619
use Predis\Client as PredisClient;
1720
use Redis;
1821

@@ -35,22 +38,22 @@ protected function setUp(): void
3538
$this->command->expects('argument')->andReturn(['foo' => 'bar']);
3639
}
3740

38-
/** @test */
39-
public function it_requires_command_as_constructor_parameter()
41+
#[Test]
42+
public function it_requires_command_as_constructor_parameter(): void
4043
{
4144
$mutex = new Mutex($this->command);
4245
$this->assertInstanceOf(Mutex::class, $mutex);
4346
}
4447

45-
/** @test */
46-
public function it_determines_ninja_mutex_lock_once_while_creation()
48+
#[Test]
49+
public function it_determines_ninja_mutex_lock_once_while_creation(): void
4750
{
4851
$mutex = new Mutex($this->command);
4952
$this->assertSame($mutex->getNinjaMutexLock(), $mutex->getNinjaMutexLock());
5053
}
5154

52-
/** @test */
53-
public function it_has_default_strategy_which_is_file()
55+
#[Test]
56+
public function it_has_default_strategy_which_is_file(): void
5457
{
5558
$this->command->expects('getMutexStrategy')->andReturn('foobar');
5659

@@ -59,8 +62,8 @@ public function it_has_default_strategy_which_is_file()
5962
$this->assertEquals($expectedLock, $mutex->getNinjaMutexLock());
6063
}
6164

62-
/** @test */
63-
public function it_supports_mysql_strategy()
65+
#[Test]
66+
public function it_supports_mysql_strategy(): void
6467
{
6568
$this->command->expects('getMutexStrategy')->andReturn('mysql');
6669

@@ -77,8 +80,8 @@ public function it_supports_mysql_strategy()
7780
$this->assertEquals($expectedLock, $mutex->getNinjaMutexLock());
7881
}
7982

80-
/** @test */
81-
public function it_supports_redis_strategy_with_phpredis_client_which_is_default()
83+
#[Test]
84+
public function it_supports_redis_strategy_with_phpredis_client_which_is_default(): void
8285
{
8386
$this->command->expects('getMutexStrategy')->andReturn('redis');
8487

@@ -90,8 +93,8 @@ public function it_supports_redis_strategy_with_phpredis_client_which_is_default
9093
$this->assertEquals($expectedLock, $mutex->getNinjaMutexLock());
9194
}
9295

93-
/** @test */
94-
public function it_supports_redis_strategy_with_predis_client()
96+
#[Test]
97+
public function it_supports_redis_strategy_with_predis_client(): void
9598
{
9699
config(['database.redis.client' => 'predis']);
97100

@@ -105,8 +108,8 @@ public function it_supports_redis_strategy_with_predis_client()
105108
$this->assertEquals($expectedLock, $mutex->getNinjaMutexLock());
106109
}
107110

108-
/** @test */
109-
public function it_supports_memcached_strategy()
111+
#[Test]
112+
public function it_supports_memcached_strategy(): void
110113
{
111114
Cache::shouldReceive('getStore')->withNoArgs()->twice()->andReturnSelf();
112115
Cache::shouldReceive('getMemcached')->withNoArgs()->twice()->andReturnSelf();
@@ -118,12 +121,8 @@ public function it_supports_memcached_strategy()
118121
$this->assertEquals($expectedLock, $mutex->getNinjaMutexLock());
119122
}
120123

121-
/**
122-
* @test
123-
* @runInSeparateProcess
124-
* @preserveGlobalState disabled
125-
*/
126-
public function it_delegates_public_method_calls_to_ninja_mutex()
124+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
125+
public function it_delegates_public_method_calls_to_ninja_mutex(): void
127126
{
128127
$ninja = mock('overload:NinjaMutex\Mutex');
129128
$ninja->expects('isLocked');

tests/TestCase.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
1515

1616
/**
1717
* Resolve application Console Kernel implementation.
18-
*
19-
* @param \Illuminate\Foundation\Application $app
20-
* @return void
2118
*/
22-
protected function resolveApplicationConsoleKernel($app)
19+
protected function resolveApplicationConsoleKernel($app): void
2320
{
2421
$app->singleton(KernelContract::class, Kernel::class);
2522

tests/WithoutOverlappingTraitTest.php

+27-36
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,71 @@
77
use Illuminated\Console\Tests\App\Console\Commands\MysqlStrategyCommand;
88
use Illuminated\Console\Tests\App\Console\Commands\NullTimeoutCommand;
99
use Illuminated\Console\Tests\App\Console\Commands\TimeoutCommand;
10+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
11+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
12+
use PHPUnit\Framework\Attributes\Test;
1013

1114
class WithoutOverlappingTraitTest extends TestCase
1215
{
13-
/** @test */
14-
public function it_adds_mutex_strategy_which_is_file_by_default()
16+
#[Test]
17+
public function it_adds_mutex_strategy_which_is_file_by_default(): void
1518
{
1619
$this->assertEquals('file', (new GenericCommand)->getMutexStrategy());
1720
}
1821

19-
/** @test */
20-
public function mutex_strategy_can_be_overloaded_by_protected_field()
22+
#[Test]
23+
public function mutex_strategy_can_be_overloaded_by_protected_field(): void
2124
{
2225
$this->assertEquals('mysql', (new MysqlStrategyCommand)->getMutexStrategy());
2326
}
2427

25-
/** @test */
26-
public function mutex_strategy_can_be_set_by_the_public_method()
28+
#[Test]
29+
public function mutex_strategy_can_be_set_by_the_public_method(): void
2730
{
2831
$command = new GenericCommand;
2932
$command->setMutexStrategy('redis');
3033

3134
$this->assertEquals('redis', $command->getMutexStrategy());
3235
}
3336

34-
/** @test */
35-
public function it_adds_mutex_timeout_which_is_zero_by_default()
37+
#[Test]
38+
public function it_adds_mutex_timeout_which_is_zero_by_default(): void
3639
{
3740
$this->assertEquals(0, (new GenericCommand)->getMutexTimeout());
3841
}
3942

40-
/** @test */
41-
public function mutex_timeout_can_be_overloaded_by_protected_field()
43+
#[Test]
44+
public function mutex_timeout_can_be_overloaded_by_protected_field(): void
4245
{
4346
$this->assertEquals(3000, (new TimeoutCommand)->getMutexTimeout());
4447
}
4548

46-
/** @test */
47-
public function mutex_timeout_can_be_set_to_null_by_protected_field()
49+
#[Test]
50+
public function mutex_timeout_can_be_set_to_null_by_protected_field(): void
4851
{
4952
$this->assertNull((new NullTimeoutCommand)->getMutexTimeout());
5053
}
5154

52-
/** @test */
53-
public function mutex_timeout_can_be_set_by_the_public_method()
55+
#[Test]
56+
public function mutex_timeout_can_be_set_by_the_public_method(): void
5457
{
5558
$command = new GenericCommand;
5659
$command->setMutexTimeout(5000);
5760

5861
$this->assertEquals(5000, $command->getMutexTimeout());
5962
}
6063

61-
/** @test */
62-
public function mutex_timeout_can_be_set_to_null_by_the_public_method()
64+
#[Test]
65+
public function mutex_timeout_can_be_set_to_null_by_the_public_method(): void
6366
{
6467
$command = new GenericCommand;
6568
$command->setMutexTimeout(null);
6669

6770
$this->assertNull($command->getMutexTimeout());
6871
}
6972

70-
/** @test */
71-
public function it_generates_mutex_name_based_on_the_command_name_and_arguments()
73+
#[Test]
74+
public function it_generates_mutex_name_based_on_the_command_name_and_arguments(): void
7275
{
7376
/** @var \Mockery\Mock|\Illuminated\Console\WithoutOverlapping $command */
7477
$command = mock(GenericCommand::class)->makePartial();
@@ -79,12 +82,8 @@ public function it_generates_mutex_name_based_on_the_command_name_and_arguments(
7982
$this->assertEquals("icmutex-icm:generic-{$hash}", $command->getMutexName());
8083
}
8184

82-
/**
83-
* @test
84-
* @runInSeparateProcess
85-
* @preserveGlobalState disabled
86-
*/
87-
public function it_allows_to_run_command_if_there_is_no_other_running_instances()
85+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
86+
public function it_allows_to_run_command_if_there_is_no_other_running_instances(): void
8887
{
8988
$mutex = mock('overload:Illuminated\Console\Mutex');
9089
$mutex->expects('acquireLock')->with(0)->andReturn(true);
@@ -93,12 +92,8 @@ public function it_allows_to_run_command_if_there_is_no_other_running_instances(
9392
$this->artisan('icm:generic');
9493
}
9594

96-
/**
97-
* @test
98-
* @runInSeparateProcess
99-
* @preserveGlobalState disabled
100-
*/
101-
public function it_blocks_if_trying_to_run_another_instance_of_the_command()
95+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
96+
public function it_blocks_if_trying_to_run_another_instance_of_the_command(): void
10297
{
10398
$this->expectException(MutexRuntimeException::class);
10499
$this->expectExceptionMessage('Command is running now!');
@@ -109,12 +104,8 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
109104
$this->artisan('icm:generic');
110105
}
111106

112-
/**
113-
* @test
114-
* @runInSeparateProcess
115-
* @preserveGlobalState disabled
116-
*/
117-
public function it_is_releasing_the_lock_after_command_execution()
107+
#[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false)]
108+
public function it_is_releasing_the_lock_after_command_execution(): void
118109
{
119110
/** @var \Mockery\Mock|\Illuminated\Console\Mutex $mutex */
120111
$mutex = mock('overload:Illuminated\Console\Mutex');

0 commit comments

Comments
 (0)