assertInstanceOf(CategorizedStatus::class, $status); } /** * @throws Exception */ public function testCreateWithInvalidStatus() { $this->expectException(Exception::class); CategorizedStatus::createFromString('some invalid status'); } /** * @throws Exception */ public function testStatusAreMappedCorrectly() { $status = CategorizedStatus::createFromString('enqueued'); $this->assertSame('created', (string)$status); $status = CategorizedStatus::createFromString('dequeued'); $this->assertSame('in_progress', (string)$status); $status = CategorizedStatus::createFromString('running'); $this->assertSame('in_progress', (string)$status); $status = CategorizedStatus::createFromString('completed'); $this->assertSame('completed', (string)$status); $status = CategorizedStatus::createFromString('failed'); $this->assertSame('failed', (string)$status); $status = CategorizedStatus::createFromString('archived'); $this->assertSame('archived', (string)$status); $status = CategorizedStatus::createFromString('cancelled'); $this->assertSame('cancelled', (string)$status); $status = CategorizedStatus::createFromString('unknown'); $this->assertSame('failed', (string)$status); } /** * @throws Exception */ public function testStatusEquals() { $statusRunning = CategorizedStatus::createFromString('dequeued'); $this->assertTrue($statusRunning->equals(CategorizedStatus::createFromString('dequeued'))); $statusCompleted = CategorizedStatus::createFromString('completed'); $this->assertTrue($statusCompleted->equals(CategorizedStatus::createFromString('completed'))); $statusArchived = CategorizedStatus::createFromString('archived'); $this->assertTrue($statusArchived->equals(CategorizedStatus::createFromString('archived'))); $statusCancelled = CategorizedStatus::createFromString('cancelled'); $this->assertTrue($statusCancelled->equals(CategorizedStatus::createFromString('cancelled'))); $statusFailed = CategorizedStatus::createFromString('failed'); $this->assertTrue($statusFailed->equals(CategorizedStatus::createFromString('unknown'))); $this->assertFalse($statusRunning->equals($statusCompleted)); $this->assertFalse($statusCompleted->equals($statusFailed)); } /** * @throws Exception */ public function testIsArchived() { $status = CategorizedStatus::createFromString('archived'); $this->assertTrue($status->isArchived()); } /** * @throws Exception */ public function testIsCancelled() { $status = CategorizedStatus::createFromString('cancelled'); $this->assertTrue($status->isCancelled()); } }