Skip to content

Commit c372dce

Browse files
Test job statuses (#42)
1 parent 046fa8a commit c372dce

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/unit/JobStatusTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Yii\Queue\Tests\unit;
6+
7+
use Yiisoft\Yii\Queue\Enum\JobStatus;
8+
use Yiisoft\Yii\Queue\Tests\TestCase;
9+
10+
class JobStatusTest extends TestCase
11+
{
12+
public function getStatusPairs(): array
13+
{
14+
return [
15+
'waiting' => [
16+
'waiting',
17+
'isWaiting',
18+
[
19+
'isReserved',
20+
'isDone',
21+
],
22+
],
23+
'reserved' => [
24+
'reserved',
25+
'isReserved',
26+
[
27+
'isWaiting',
28+
'isDone',
29+
],
30+
],
31+
'done' => [
32+
'done',
33+
'isDone',
34+
[
35+
'isWaiting',
36+
'isReserved',
37+
],
38+
],
39+
];
40+
}
41+
42+
/**
43+
* @dataProvider getStatusPairs
44+
*/
45+
public function testInstanceValue(string $statusName, string $positiveMethod, array $negatives): void
46+
{
47+
$status = JobStatus::$statusName();
48+
49+
$this->assertTrue($status->$positiveMethod(), "$positiveMethod must be true for status $statusName");
50+
foreach ($negatives as $negative) {
51+
$this->assertFalse($status->$negative(), "$negative must be false for status $statusName");
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)