22 use PHPUnit\Framework\TestCase;
53 $jobQueue =
new JobQueue(44,
'readmeoss',
'2024-07-03 20:41:49',
'2024-07-03 20:41:50',
54 'Completed', 0,
null, [], 0,
true,
false,
true,
55 [
'text' =>
'ReadMeOss',
'link' =>
'http://localhost/repo/api/v1/report/16']
58 if ($version == ApiVersion::V2){
62 'queueDate' =>
'01-01-2020',
64 'userName' =>
"fossy",
65 'groupName' =>
"fossy",
67 'status' =>
'Processing',
68 'jobQueue' => $jobQueue->getArray()
72 $userDao = M::mock(UserDao::class);
73 $container = M::mock(
'ContainerBuilder');
74 $container->shouldReceive(
'get')->with(
'dao.user')->andReturn($userDao);
75 $userDao->shouldReceive(
'getUserName')->with(2)->andReturn(
'fossy');
76 $userDao->shouldReceive(
'getGroupNameById')->with(2)->andReturn(
'fossy');
81 'queueDate' =>
'01-01-2020',
86 'status' =>
'Processing'
90 $actualJob =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing', $jobQueue->getArray());
92 $this->assertEquals($expectedStatus, $actualJob->getArray($version));
96 public function testGetId()
98 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
99 $this->assertEquals(22, $job->getId());
102 public function testGetName()
104 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
105 $this->assertEquals(
'ojo', $job->getName());
108 public function testGetQueueDate()
110 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
111 $this->assertEquals(
'01-01-2020', $job->getQueueDate());
114 public function testGetUploadId()
116 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
117 $this->assertEquals(4, $job->getUploadId());
120 public function testGetUserId()
122 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
123 $this->assertEquals(2, $job->getUserId());
126 public function testGetGroupId()
128 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
129 $this->assertEquals(2, $job->getGroupId());
132 public function testGetEta()
134 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
135 $this->assertEquals(3, $job->getEta());
138 public function testGetStatus()
140 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
141 $this->assertEquals(
'Processing', $job->getStatus());
144 public function testGetJobQueue()
146 $jobQueue =
new JobQueue(44,
'readmeoss',
'2024-07-03 20:41:49',
'2024-07-03 20:41:50',
147 'Completed', 0,
null, [], 0,
true,
false,
true,
148 [
'text' =>
'ReadMeOss',
'link' =>
'http://localhost/repo/api/v1/report/16']
150 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing', $jobQueue->getArray());
151 $this->assertEquals($jobQueue->getArray(), $job->getJobQueue());
155 public function testSetName()
157 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
158 $job->setName(
'newName');
159 $this->assertEquals(
'newName', $job->getName());
162 public function testSetQueueDate()
164 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
165 $job->setQueueDate(
'02-02-2020');
166 $this->assertEquals(
'02-02-2020', $job->getQueueDate());
169 public function testSetUploadId()
171 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
172 $job->setUploadId(5);
173 $this->assertEquals(5, $job->getUploadId());
176 public function testSetUserId()
178 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
180 $this->assertEquals(3, $job->getUserId());
183 public function testSetGroupId()
185 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
187 $this->assertEquals(4, $job->getGroupId());
189 public function testSetEta()
191 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
193 $this->assertEquals(10, $job->getEta());
196 public function testSetStatus()
198 $job =
new Job(22,
'ojo',
'01-01-2020', 4, 2, 2, 3,
'Processing');
199 $job->setStatus(
'Completed');
200 $this->assertEquals(
'Completed', $job->getStatus());
Model class to hold JobQueue info.