CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C Queue 2.x API

  • Project:
    • Queue
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 2.x
      • 2.x
      • 1.x

Namespaces

  • Cake\Queue
    • Command
    • Consumption
    • Job
    • Listener
    • Mailer
    • Model
    • Queue
    • TestSuite
      • Constraint
      • Transport

Trait QueueTrait

Queue Trait

Make assertions on jobs queued through QueueManager.

After adding the trait to your test case, all jobs will be captured instead of being queued, allowing you to make assertions.

Usage:

class MyTest extends TestCase
{
    use QueueTrait;

public function testJobQueued(): void
    {
        QueueManager::push('MyJob', ['data' => 'value']);

$this->assertJobQueued('MyJob');
        $this->assertJobQueuedWith('MyJob', ['data' => 'value']);
    }
}
Namespace: Cake\Queue\TestSuite

Method Summary

  • assertJobCount() public

    Assert a specific count of jobs were queued

  • assertJobNotQueued() public

    Assert a job was not queued

  • assertJobQueued() public

    Assert a job was queued

  • assertJobQueuedTimes() public

    Assert a job was queued a specific number of times

  • assertJobQueuedToQueue() public

    Assert a job was queued to a specific queue

  • assertJobQueuedWith() public

    Assert a job was queued with specific data

  • assertJobQueuedWithDelay() public

    Assert a job was queued with delay

  • assertJobQueuedWithPriority() public

    Assert a job was queued with priority

  • assertNoJobsQueued() public

    Assert no jobs were queued

  • cleanupQueueTrait() public

    Cleanup queued jobs

  • getQueuedJobs() public

    Get all queued jobs

  • getQueuedJobsByClass() public

    Get queued jobs by class

  • getQueuedJobsByConfig() public

    Get queued jobs by config name

  • getQueuedJobsByQueue() public

    Get queued jobs by queue name

  • setupTestQueueClient() public

    Setup test queue client

Method Detail

assertJobCount() ¶ public

assertJobCount(int $count, string $message = ''): void

Assert a specific count of jobs were queued

Parameters
int $count

Expected job count

string $message optional

Optional assertion message

Returns
void

assertJobNotQueued() ¶ public

assertJobNotQueued(string $jobClass, string $message = ''): void

Assert a job was not queued

Parameters
string $jobClass

Job class name

string $message optional

Optional assertion message

Returns
void

assertJobQueued() ¶ public

assertJobQueued(string $jobClass, string $message = ''): void

Assert a job was queued

Parameters
string $jobClass

Job class name

string $message optional

Optional assertion message

Returns
void

assertJobQueuedTimes() ¶ public

assertJobQueuedTimes(string $jobClass, int $times, string $message = ''): void

Assert a job was queued a specific number of times

Parameters
string $jobClass

Job class name

int $times

Expected number of times

string $message optional

Optional assertion message

Returns
void

assertJobQueuedToQueue() ¶ public

assertJobQueuedToQueue(string $queue, string $jobClass, string $message = ''): void

Assert a job was queued to a specific queue

Parameters
string $queue

Queue name

string $jobClass

Job class name

string $message optional

Optional assertion message

Returns
void

assertJobQueuedWith() ¶ public

assertJobQueuedWith(string $jobClass, array<string, mixed> $data, string $message = ''): void

Assert a job was queued with specific data

Parameters
string $jobClass

Job class name

array<string, mixed> $data

Expected data

string $message optional

Optional assertion message

Returns
void

assertJobQueuedWithDelay() ¶ public

assertJobQueuedWithDelay(string $jobClass, int $delay, string $message = ''): void

Assert a job was queued with delay

Parameters
string $jobClass

Job class name

int $delay

Expected delay in seconds

string $message optional

Optional assertion message

Returns
void

assertJobQueuedWithPriority() ¶ public

assertJobQueuedWithPriority(string $jobClass, string|int $priority, string $message = ''): void

Assert a job was queued with priority

Parameters
string $jobClass

Job class name

string|int $priority

Expected priority

string $message optional

Optional assertion message

Returns
void

assertNoJobsQueued() ¶ public

assertNoJobsQueued(string $message = ''): void

Assert no jobs were queued

Parameters
string $message optional

Optional assertion message

Returns
void

cleanupQueueTrait() ¶ public

cleanupQueueTrait(): void

Cleanup queued jobs

Clears all captured jobs after each test.

Returns
void

getQueuedJobs() ¶ public

getQueuedJobs(): array<array<string, mixed>>

Get all queued jobs

Returns
array<array<string, mixed>>

getQueuedJobsByClass() ¶ public

getQueuedJobsByClass(string $jobClass): array<array<string, mixed>>

Get queued jobs by class

Parameters
string $jobClass

Job class name

Returns
array<array<string, mixed>>

getQueuedJobsByConfig() ¶ public

getQueuedJobsByConfig(string $config): array<array<string, mixed>>

Get queued jobs by config name

Parameters
string $config

Config name

Returns
array<array<string, mixed>>

getQueuedJobsByQueue() ¶ public

getQueuedJobsByQueue(string $queue): array<array<string, mixed>>

Get queued jobs by queue name

Parameters
string $queue

Queue name

Returns
array<array<string, mixed>>

setupTestQueueClient() ¶ public

setupTestQueueClient(): void

Setup test queue client

Replaces all queue configs with test transport to capture jobs instead of queuing them.

Returns
void
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs