Skip to content

Commit 319cc36

Browse files
Fixed the job status hasEnded() / isActive() helper methods
1 parent 1067705 commit 319cc36

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/Models/JobStatus.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class JobStatus extends Enum implements JobStatusContract
4444

4545
public function isActive(): bool
4646
{
47-
return $this->isAnyOf(self::QUEUED(), self::PROCESSING());
47+
return in_array($this->value(), [static::QUEUED, static::PROCESSING]);
4848
}
4949

5050
public function hasEnded(): bool
5151
{
52-
return $this->isAnyOf(self::COMPLETED(), self::FAILED());
52+
return in_array($this->value(), [static::COMPLETED, static::FAILED]);
5353
}
5454
}

tests/JobStatusTest.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Konekt\History\Tests;
6+
7+
use Konekt\History\Models\JobStatus;
8+
9+
class JobStatusTest extends TestCase
10+
{
11+
/** @test */
12+
public function it_can_tell_whether_it_has_ended()
13+
{
14+
$completed = JobStatus::COMPLETED();
15+
$failed = JobStatus::FAILED();
16+
$queued = JobStatus::QUEUED();
17+
$processing = JobStatus::PROCESSING();
18+
19+
$this->assertTrue($completed->hasEnded());
20+
$this->assertTrue($failed->hasEnded());
21+
$this->assertFalse($queued->hasEnded());
22+
$this->assertFalse($processing->hasEnded());
23+
}
24+
25+
/** @test */
26+
public function it_can_tell_whether_it_is_active()
27+
{
28+
$queued = JobStatus::QUEUED();
29+
$processing = JobStatus::PROCESSING();
30+
$completed = JobStatus::COMPLETED();
31+
$failed = JobStatus::FAILED();
32+
33+
$this->assertTrue($queued->isActive());
34+
$this->assertTrue($processing->isActive());
35+
$this->assertFalse($completed->isActive());
36+
$this->assertFalse($failed->isActive());
37+
}
38+
}

0 commit comments

Comments
 (0)