public function testCommand() { $timestamp = 1326670266.115; $datestamp = new \DateTime(); $datestamp->setTimestamp($timestamp); $attributes = ['reason' => 'Gremlins']; $event_id = 'test_' . rand(10000, 99999); $history = new WorkflowHistory(); $command = new WorkflowExecutionFailedCommand($datestamp, $attributes, $event_id); $this->assertFalse($history->hasWorkflowFailed()); $this->assertNull($history->getTimeStarted()); $this->assertNull($history->getInput()); $command->apply($history); $this->assertTrue($history->hasWorkflowFailed()); $this->assertEquals('1326670266', $history->getTimeEnded()->format('U')); $this->assertEquals('Failed: Gremlins', $history->getErrorMessages()[0]); }
public function testCommand() { $timestamp = 1326670266.115; $datestamp = new \DateTime(); $datestamp->setTimestamp($timestamp); $attributes = ['activityType' => ['name' => 'TestActivity', 'version' => 123], 'cause' => 'Gremlins']; $event_id = 'test_' . rand(10000, 99999); $history = new WorkflowHistory(); $command = new ScheduleActivityTaskFailedCommand($datestamp, $attributes, $event_id); $this->assertFalse($history->hasWorkflowFailed()); $this->assertNull($history->getTimeStarted()); $this->assertNull($history->getInput()); $command->apply($history); // When a schedule fails, we should mark the workflow as critically failed, but it still hasn't ended // This should act as an indication to fail the entire workflow $this->assertTrue($history->hasWorkflowFailed()); $this->assertNull($history->getTimeEnded()); $this->assertEquals('Unable to schedule activity task: TestActivity-123 (Gremlins)', $history->getErrorMessages()[0]); }