Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
},
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0.0",
"cakephp/cakephp": "dev-5.next as 5.1.0",
"enqueue/simple-client": "^0.10",
"psr/log": "^3.0"
},
"require-dev": {
"cakephp/bake": "^3.0.0",
"cakephp/bake": "dev-3.next",
"cakephp/cakephp-codesniffer": "^5.0",
"enqueue/fs": "^0.10",
"phpunit/phpunit": "^10.1.0"
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
},
"suggest": {
"cakephp/bake": "Required if you want to generate jobs.",
Expand Down
37 changes: 14 additions & 23 deletions tests/TestCase/Command/WorkerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use Cake\Queue\Test\test_app\src\Job\LogToDebugWithServiceJob;
use Cake\Queue\Test\TestCase\DebugLogTrait;
use Cake\TestSuite\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use TestApp\Job\LogToDebugJob;
use TestApp\Job\RequeueJob;
use TestApp\WelcomeMailerListener;
Expand All @@ -48,9 +50,8 @@ public function testDescriptionOutput()

/**
* Test that queue will run for one second
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesStart()
{
Configure::write('Queue', [
Expand All @@ -65,9 +66,8 @@ public function testQueueProcessesStart()

/**
* Test that queue will run for one second with valid listener
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesWithListener()
{
Configure::write('Queue', [
Expand All @@ -83,9 +83,8 @@ public function testQueueProcessesWithListener()

/**
* Test that queue will abort when the passed config is not present in the app configuration.
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueWillAbortWithMissingConfig()
{
Configure::write('Queue', [
Expand All @@ -102,9 +101,8 @@ public function testQueueWillAbortWithMissingConfig()

/**
* Test that queue will abort with invalid listener
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesWithInvalidListener()
{
Configure::write('Queue', [
Expand All @@ -121,9 +119,8 @@ public function testQueueProcessesWithInvalidListener()

/**
* Test that queue will write to specified logger option
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesWithLogger()
{
Configure::write('Queue', [
Expand Down Expand Up @@ -156,10 +153,9 @@ public static function dataProviderCallableTypes(): array

/**
* Start up the worker queue, push a job, and see that it processes
*
* @dataProvider dataProviderCallableTypes
* @runInSeparateProcess
*/
#[DataProvider('dataProviderCallableTypes')]
#[RunInSeparateProcess]
public function testQueueProcessesJob($callable)
{
$config = [
Expand All @@ -185,9 +181,8 @@ public function testQueueProcessesJob($callable)

/**
* Set the processor name, Start up the worker queue, push a job, and see that it processes
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesJobWithProcessor()
{
$config = [
Expand All @@ -212,9 +207,8 @@ public function testQueueProcessesJobWithProcessor()

/**
* Test non-default queue name
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesJobWithOtherQueue()
{
$config = [
Expand All @@ -240,9 +234,8 @@ public function testQueueProcessesJobWithOtherQueue()

/**
* Test max-attempts option
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesJobWithMaxAttempts()
{
$config = [
Expand All @@ -268,9 +261,8 @@ public function testQueueProcessesJobWithMaxAttempts()

/**
* Test DI service injection works in tasks
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesJobWithDIService()
{
$this->skipIf(version_compare(Configure::version(), '4.2', '<'), 'DI Container is only available since CakePHP 4.2');
Expand All @@ -296,9 +288,8 @@ public function testQueueProcessesJobWithDIService()

/**
* Test that queue will process when a unique cache is configured.
*
* @runInSeparateProcess
*/
#[RunInSeparateProcess]
public function testQueueProcessesWithUniqueCacheConfigured()
{
$config = [
Expand Down
7 changes: 3 additions & 4 deletions tests/TestCase/Consumption/LimitAttemptsExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Cake\Queue\Test\TestCase\DebugLogTrait;
use Cake\TestSuite\TestCase;
use Enqueue\Consumption\ChainExtension;
use PHPUnit\Framework\Attributes\After;
use PHPUnit\Framework\Attributes\BeforeClass;
use Psr\Log\NullLogger;
use TestApp\Job\MaxAttemptsIsThreeJob;
use TestApp\Job\RequeueJob;
Expand All @@ -28,10 +30,7 @@ public function setUp(): void
EventManager::instance()->setEventList(new EventList());
}

/**
* @beforeClass
* @after
*/
#[BeforeClass, After]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we allow this, or should each attribute be in its own line?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. We should allow simple forms for simple usage 😄

public static function dropConfigs()
{
Log::drop('debug');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
use Cake\Queue\QueueManager;
use Cake\TestSuite\TestCase;
use Enqueue\Consumption\ChainExtension;
use PHPUnit\Framework\Attributes\After;
use PHPUnit\Framework\Attributes\BeforeClass;
use Psr\Log\NullLogger;
use TestApp\Job\UniqueJob;

class RemoveUniqueJobIdFromCacheExtensionTest extends TestCase
{
/**
* @beforeClass
* @after
*/
#[BeforeClass, After]
public static function dropConfigs()
{
Log::drop('debug');
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Listener/FailedJobsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Cake\TestSuite\TestCase;
use Enqueue\Null\NullConnectionFactory;
use Enqueue\Null\NullMessage;
use PHPUnit\Framework\Attributes\DataProvider;
use RuntimeException;
use stdClass;
use TestApp\Job\LogToDebugJob;
Expand Down Expand Up @@ -113,9 +114,9 @@ public static function storeFailedJobExceptionDataProvider()
}

/**
* @dataProvider storeFailedJobExceptionDataProvider
* @return void
*/
#[DataProvider('storeFailedJobExceptionDataProvider')]
public function testStoreFailedJobException($eventData, $exceptionMessage)
{
$tableLocator = $this
Expand Down
5 changes: 2 additions & 3 deletions tests/TestCase/Mailer/QueueTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Cake\Mailer\Exception\MissingActionException;
use Cake\Queue\QueueManager;
use Cake\TestSuite\TestCase;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use TestApp\WelcomeMailer;

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

/**
* Test that QueueTrait calls push
*
* @runInSeparateProcess
* @return @void
*/
#[RunInSeparateProcess]
public function testQueueTraitCallsPush()
{
$queue = new WelcomeMailer();
Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase/Queue/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Enqueue\Null\NullConnectionFactory;
use Enqueue\Null\NullMessage;
use Interop\Queue\Processor as InteropProcessor;
use PHPUnit\Framework\Attributes\DataProvider;
use TestApp\TestProcessor;

class ProcessorTest extends TestCase
Expand Down Expand Up @@ -53,10 +54,10 @@ public static function dataProviderTestProcess(): array
* @param string $jobMethod The method name to run
* @param string $expected The expected process result.
* @param string $logMessage The log message based on process result.
* @param string $dispacthedEvent The dispatched event based on process result.
* @dataProvider dataProviderTestProcess
* @param string $dispatchedEvent The dispatched event based on process result.
* @return void
*/
#[DataProvider('dataProviderTestProcess')]
public function testProcess($jobMethod, $expected, $logMessage, $dispatchedEvent)
{
$messageBody = [
Expand Down