forked from cakephp/queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJobQueued.php
More file actions
48 lines (42 loc) · 884 Bytes
/
JobQueued.php
File metadata and controls
48 lines (42 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace Cake\Queue\TestSuite\Constraint\Queue;
/**
* JobQueued
*
* Asserts that a job of a specific class was queued
*
* @internal
*/
class JobQueued extends QueueConstraintBase
{
/**
* Checks if job was queued
*
* @param mixed $other Job class name
* @return bool
*/
public function matches(mixed $other): bool
{
$jobClass = $other;
$jobs = $this->getJobs();
foreach ($jobs as $job) {
if ($job['jobClass'] === $jobClass) {
return true;
}
}
return false;
}
/**
* Assertion message
*
* @return string
*/
public function toString(): string
{
if ($this->at !== null) {
return sprintf('job #%d was queued', $this->at);
}
return 'job was queued';
}
}