-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTaskExecutionTest.php
More file actions
130 lines (100 loc) · 3.89 KB
/
Copy pathTaskExecutionTest.php
File metadata and controls
130 lines (100 loc) · 3.89 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Task\Tests\Unit\Execution;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Execution\TaskExecution;
use Task\Task;
use Task\TaskStatus;
/**
* Tests for TaskExecution.
*/
class TaskExecutionTest extends TestCase
{
use ProphecyTrait;
public function testUuid()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable(), null, '123-123-123');
$this->assertEquals('123-123-123', $execution->getUuid());
}
public function testDuration()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getDuration());
$execution->setDuration(1.222);
$this->assertEquals(1.222, $execution->getDuration());
}
public function testEndTime()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getEndTime());
$date = new \DateTimeImmutable('now');
$execution->setEndTime($date);
$this->assertEquals($date, $execution->getEndTime());
}
public function testException()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getException());
$exception = new \Exception();
$execution->setException($exception);
$this->assertEquals($exception, $execution->getException());
}
public function testResult()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getResult());
$result = 'test result';
$execution->setResult($result);
$this->assertEquals($result, $execution->getResult());
}
public function testStartTime()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getStartTime());
$date = new \DateTimeImmutable('now');
$execution->setStartTime($date);
$this->assertEquals($date, $execution->getStartTime());
}
public function testStatus()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertNull($execution->getStatus());
$execution->setStatus(TaskStatus::COMPLETED);
$this->assertEquals(TaskStatus::COMPLETED, $execution->getStatus());
}
public function testWorkload()
{
$task = $this->prophesize(Task::class);
$workload = 'test workload';
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable(), $workload);
$this->assertEquals($workload, $execution->getWorkload());
}
public function testHandlerClass()
{
$task = $this->prophesize(Task::class);
$execution = new TaskExecution($task->reveal(), \stdClass::class, new \DateTimeImmutable());
$this->assertEquals(\stdClass::class, $execution->getHandlerClass());
}
public function testScheduleTime()
{
$task = $this->prophesize(Task::class);
$date = new \DateTimeImmutable('now');
$execution = new TaskExecution($task->reveal(), \stdClass::class, $date);
$this->assertEquals($date, $execution->getScheduleTime());
}
}