Skip to content

Commit 8a370aa

Browse files
authored
Merge pull request #149 from cakephp/2.next-phpunit11
add phpunit 11 support
2 parents 22f2fa5 + 943b3de commit 8a370aa

File tree

7 files changed

+30
-40
lines changed

7 files changed

+30
-40
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
},
2323
"require": {
2424
"php": ">=8.1",
25-
"cakephp/cakephp": "^5.0.0",
25+
"cakephp/cakephp": "dev-5.next as 5.1.0",
2626
"enqueue/simple-client": "^0.10",
2727
"psr/log": "^3.0"
2828
},
2929
"require-dev": {
30-
"cakephp/bake": "^3.0.0",
30+
"cakephp/bake": "dev-3.next",
3131
"cakephp/cakephp-codesniffer": "^5.0",
3232
"enqueue/fs": "^0.10",
33-
"phpunit/phpunit": "^10.1.0"
33+
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
3434
},
3535
"suggest": {
3636
"cakephp/bake": "Required if you want to generate jobs.",

tests/TestCase/Command/WorkerCommandTest.php

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use Cake\Queue\Test\test_app\src\Job\LogToDebugWithServiceJob;
2424
use Cake\Queue\Test\TestCase\DebugLogTrait;
2525
use Cake\TestSuite\TestCase;
26+
use PHPUnit\Framework\Attributes\DataProvider;
27+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2628
use TestApp\Job\LogToDebugJob;
2729
use TestApp\Job\RequeueJob;
2830
use TestApp\WelcomeMailerListener;
@@ -48,9 +50,8 @@ public function testDescriptionOutput()
4850

4951
/**
5052
* Test that queue will run for one second
51-
*
52-
* @runInSeparateProcess
5353
*/
54+
#[RunInSeparateProcess]
5455
public function testQueueProcessesStart()
5556
{
5657
Configure::write('Queue', [
@@ -65,9 +66,8 @@ public function testQueueProcessesStart()
6566

6667
/**
6768
* Test that queue will run for one second with valid listener
68-
*
69-
* @runInSeparateProcess
7069
*/
70+
#[RunInSeparateProcess]
7171
public function testQueueProcessesWithListener()
7272
{
7373
Configure::write('Queue', [
@@ -83,9 +83,8 @@ public function testQueueProcessesWithListener()
8383

8484
/**
8585
* Test that queue will abort when the passed config is not present in the app configuration.
86-
*
87-
* @runInSeparateProcess
8886
*/
87+
#[RunInSeparateProcess]
8988
public function testQueueWillAbortWithMissingConfig()
9089
{
9190
Configure::write('Queue', [
@@ -102,9 +101,8 @@ public function testQueueWillAbortWithMissingConfig()
102101

103102
/**
104103
* Test that queue will abort with invalid listener
105-
*
106-
* @runInSeparateProcess
107104
*/
105+
#[RunInSeparateProcess]
108106
public function testQueueProcessesWithInvalidListener()
109107
{
110108
Configure::write('Queue', [
@@ -121,9 +119,8 @@ public function testQueueProcessesWithInvalidListener()
121119

122120
/**
123121
* Test that queue will write to specified logger option
124-
*
125-
* @runInSeparateProcess
126122
*/
123+
#[RunInSeparateProcess]
127124
public function testQueueProcessesWithLogger()
128125
{
129126
Configure::write('Queue', [
@@ -156,10 +153,9 @@ public static function dataProviderCallableTypes(): array
156153

157154
/**
158155
* Start up the worker queue, push a job, and see that it processes
159-
*
160-
* @dataProvider dataProviderCallableTypes
161-
* @runInSeparateProcess
162156
*/
157+
#[DataProvider('dataProviderCallableTypes')]
158+
#[RunInSeparateProcess]
163159
public function testQueueProcessesJob($callable)
164160
{
165161
$config = [
@@ -185,9 +181,8 @@ public function testQueueProcessesJob($callable)
185181

186182
/**
187183
* Set the processor name, Start up the worker queue, push a job, and see that it processes
188-
*
189-
* @runInSeparateProcess
190184
*/
185+
#[RunInSeparateProcess]
191186
public function testQueueProcessesJobWithProcessor()
192187
{
193188
$config = [
@@ -212,9 +207,8 @@ public function testQueueProcessesJobWithProcessor()
212207

213208
/**
214209
* Test non-default queue name
215-
*
216-
* @runInSeparateProcess
217210
*/
211+
#[RunInSeparateProcess]
218212
public function testQueueProcessesJobWithOtherQueue()
219213
{
220214
$config = [
@@ -240,9 +234,8 @@ public function testQueueProcessesJobWithOtherQueue()
240234

241235
/**
242236
* Test max-attempts option
243-
*
244-
* @runInSeparateProcess
245237
*/
238+
#[RunInSeparateProcess]
246239
public function testQueueProcessesJobWithMaxAttempts()
247240
{
248241
$config = [
@@ -268,9 +261,8 @@ public function testQueueProcessesJobWithMaxAttempts()
268261

269262
/**
270263
* Test DI service injection works in tasks
271-
*
272-
* @runInSeparateProcess
273264
*/
265+
#[RunInSeparateProcess]
274266
public function testQueueProcessesJobWithDIService()
275267
{
276268
$this->skipIf(version_compare(Configure::version(), '4.2', '<'), 'DI Container is only available since CakePHP 4.2');
@@ -296,9 +288,8 @@ public function testQueueProcessesJobWithDIService()
296288

297289
/**
298290
* Test that queue will process when a unique cache is configured.
299-
*
300-
* @runInSeparateProcess
301291
*/
292+
#[RunInSeparateProcess]
302293
public function testQueueProcessesWithUniqueCacheConfigured()
303294
{
304295
$config = [

tests/TestCase/Consumption/LimitAttemptsExtensionTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Cake\Queue\Test\TestCase\DebugLogTrait;
1414
use Cake\TestSuite\TestCase;
1515
use Enqueue\Consumption\ChainExtension;
16+
use PHPUnit\Framework\Attributes\After;
17+
use PHPUnit\Framework\Attributes\BeforeClass;
1618
use Psr\Log\NullLogger;
1719
use TestApp\Job\MaxAttemptsIsThreeJob;
1820
use TestApp\Job\RequeueJob;
@@ -28,10 +30,7 @@ public function setUp(): void
2830
EventManager::instance()->setEventList(new EventList());
2931
}
3032

31-
/**
32-
* @beforeClass
33-
* @after
34-
*/
33+
#[BeforeClass, After]
3534
public static function dropConfigs()
3635
{
3736
Log::drop('debug');

tests/TestCase/Consumption/RemoveUniqueJobIdFromCacheExtensionTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
use Cake\Queue\QueueManager;
1212
use Cake\TestSuite\TestCase;
1313
use Enqueue\Consumption\ChainExtension;
14+
use PHPUnit\Framework\Attributes\After;
15+
use PHPUnit\Framework\Attributes\BeforeClass;
1416
use Psr\Log\NullLogger;
1517
use TestApp\Job\UniqueJob;
1618

1719
class RemoveUniqueJobIdFromCacheExtensionTest extends TestCase
1820
{
19-
/**
20-
* @beforeClass
21-
* @after
22-
*/
21+
#[BeforeClass, After]
2322
public static function dropConfigs()
2423
{
2524
Log::drop('debug');

tests/TestCase/Listener/FailedJobsListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Cake\TestSuite\TestCase;
2929
use Enqueue\Null\NullConnectionFactory;
3030
use Enqueue\Null\NullMessage;
31+
use PHPUnit\Framework\Attributes\DataProvider;
3132
use RuntimeException;
3233
use stdClass;
3334
use TestApp\Job\LogToDebugJob;
@@ -113,9 +114,9 @@ public static function storeFailedJobExceptionDataProvider()
113114
}
114115

115116
/**
116-
* @dataProvider storeFailedJobExceptionDataProvider
117117
* @return void
118118
*/
119+
#[DataProvider('storeFailedJobExceptionDataProvider')]
119120
public function testStoreFailedJobException($eventData, $exceptionMessage)
120121
{
121122
$tableLocator = $this

tests/TestCase/Mailer/QueueTraitTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Cake\Mailer\Exception\MissingActionException;
2020
use Cake\Queue\QueueManager;
2121
use Cake\TestSuite\TestCase;
22+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2223
use TestApp\WelcomeMailer;
2324

2425
class QueueTraitTest extends TestCase
@@ -38,10 +39,8 @@ public function testQueueTraitTestThrowsMissingActionException()
3839

3940
/**
4041
* Test that QueueTrait calls push
41-
*
42-
* @runInSeparateProcess
43-
* @return @void
4442
*/
43+
#[RunInSeparateProcess]
4544
public function testQueueTraitCallsPush()
4645
{
4746
$queue = new WelcomeMailer();

tests/TestCase/Queue/ProcessorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Enqueue\Null\NullConnectionFactory;
2626
use Enqueue\Null\NullMessage;
2727
use Interop\Queue\Processor as InteropProcessor;
28+
use PHPUnit\Framework\Attributes\DataProvider;
2829
use TestApp\TestProcessor;
2930

3031
class ProcessorTest extends TestCase
@@ -53,10 +54,10 @@ public static function dataProviderTestProcess(): array
5354
* @param string $jobMethod The method name to run
5455
* @param string $expected The expected process result.
5556
* @param string $logMessage The log message based on process result.
56-
* @param string $dispacthedEvent The dispatched event based on process result.
57-
* @dataProvider dataProviderTestProcess
57+
* @param string $dispatchedEvent The dispatched event based on process result.
5858
* @return void
5959
*/
60+
#[DataProvider('dataProviderTestProcess')]
6061
public function testProcess($jobMethod, $expected, $logMessage, $dispatchedEvent)
6162
{
6263
$messageBody = [

0 commit comments

Comments
 (0)