|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2017 Francois-Xavier Soubirou. |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of ci-report. |
|
6
|
|
|
* |
|
7
|
|
|
* ci-report is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* ci-report is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
* along with ci-report. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
namespace AppBundle\Entity; |
|
21
|
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
23
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Test. |
|
27
|
|
|
* |
|
28
|
|
|
* @ORM\Table(name="cir_test") |
|
29
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\TestRepository") |
|
30
|
|
|
*/ |
|
31
|
|
|
class Test |
|
32
|
|
|
{ |
|
33
|
|
|
const DEFAULT_PACKAGE = '_root_'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var int |
|
37
|
|
|
* |
|
38
|
|
|
* @ORM\Column(name="id", type="integer") |
|
39
|
|
|
* @ORM\Id |
|
40
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
41
|
|
|
*/ |
|
42
|
|
|
private $id; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string Name |
|
46
|
|
|
* |
|
47
|
|
|
* @ORM\Column(name="name", type="string", length=256) |
|
48
|
|
|
*/ |
|
49
|
|
|
private $name; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var string classname |
|
53
|
|
|
* |
|
54
|
|
|
* @ORM\Column(name="classname", type="string", length=256) |
|
55
|
|
|
*/ |
|
56
|
|
|
private $className; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var string package |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\Column(name="package", type="string", length=256) |
|
62
|
|
|
*/ |
|
63
|
|
|
private $package; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var int |
|
67
|
|
|
* |
|
68
|
|
|
* @ORM\Column(name="passed", type="smallint") |
|
69
|
|
|
*/ |
|
70
|
|
|
private $passed; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var int |
|
74
|
|
|
* |
|
75
|
|
|
* @ORM\Column(name="failed", type="smallint") |
|
76
|
|
|
*/ |
|
77
|
|
|
private $failed; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var int |
|
81
|
|
|
* |
|
82
|
|
|
* @ORM\Column(name="errored", type="smallint") |
|
83
|
|
|
*/ |
|
84
|
|
|
private $errored; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @var int |
|
88
|
|
|
* |
|
89
|
|
|
* @ORM\Column(name="skipped", type="smallint") |
|
90
|
|
|
*/ |
|
91
|
|
|
private $skipped; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @var float |
|
95
|
|
|
* |
|
96
|
|
|
* @ORM\Column(name="duration", type="float") |
|
97
|
|
|
*/ |
|
98
|
|
|
private $duration; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @var string |
|
102
|
|
|
* |
|
103
|
|
|
* @ORM\Column(name="system_out", type="text") |
|
104
|
|
|
*/ |
|
105
|
|
|
private $systemOut; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @var string |
|
109
|
|
|
* |
|
110
|
|
|
* @ORM\Column(name="system_err", type="text") |
|
111
|
|
|
*/ |
|
112
|
|
|
private $systemErr; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @Gedmo\SortablePosition |
|
116
|
|
|
* @ORM\Column(name="position", type="integer") |
|
117
|
|
|
*/ |
|
118
|
|
|
private $position; |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @var Suite |
|
122
|
|
|
* |
|
123
|
|
|
* @Gedmo\SortableGroup |
|
124
|
|
|
* @ORM\ManyToOne(targetEntity="Suite") |
|
125
|
|
|
* @ORM\JoinColumn(name="suite_id", referencedColumnName="id", nullable=false) |
|
126
|
|
|
*/ |
|
127
|
|
|
private $suite; |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Constructor. |
|
131
|
|
|
* |
|
132
|
|
|
* @param Suite $suite |
|
133
|
|
|
*/ |
|
134
|
|
|
public function __construct($suite) |
|
135
|
|
|
{ |
|
136
|
|
|
$this->setSuite($suite); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Get id. |
|
141
|
|
|
* |
|
142
|
|
|
* @return int |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getId() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->id; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Set name. |
|
151
|
|
|
* |
|
152
|
|
|
* @param string $name |
|
153
|
|
|
* |
|
154
|
|
|
* @return Test |
|
155
|
|
|
*/ |
|
156
|
|
|
public function setName($name) |
|
157
|
|
|
{ |
|
158
|
|
|
$this->name = $name; |
|
159
|
|
|
|
|
160
|
|
|
return $this; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Get name. |
|
165
|
|
|
* |
|
166
|
|
|
* @return string |
|
167
|
|
|
*/ |
|
168
|
|
|
public function getName() |
|
169
|
|
|
{ |
|
170
|
|
|
return $this->name; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Set classname. |
|
175
|
|
|
* |
|
176
|
|
|
* @param string $classname |
|
177
|
|
|
* |
|
178
|
|
|
* @return Test |
|
179
|
|
|
*/ |
|
180
|
|
|
public function setClassName($classname) |
|
181
|
|
|
{ |
|
182
|
|
|
$this->className = $classname; |
|
183
|
|
|
|
|
184
|
|
|
return $this; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Get classname. |
|
189
|
|
|
* |
|
190
|
|
|
* @return string |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getClassName() |
|
193
|
|
|
{ |
|
194
|
|
|
return $this->className; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Set package. |
|
199
|
|
|
* |
|
200
|
|
|
* @param string $package |
|
201
|
|
|
* |
|
202
|
|
|
* @return Test |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setPackage($package) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->package = $package; |
|
207
|
|
|
|
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Get package. |
|
213
|
|
|
* |
|
214
|
|
|
* @return string |
|
215
|
|
|
*/ |
|
216
|
|
|
public function getPackage() |
|
217
|
|
|
{ |
|
218
|
|
|
return $this->package; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Set full class name. |
|
223
|
|
|
* |
|
224
|
|
|
* @return Test |
|
225
|
|
|
*/ |
|
226
|
|
|
public function setFullClassName($fullClassName) |
|
227
|
|
|
{ |
|
228
|
|
|
if (substr_count($fullClassName, '.') > 0) { |
|
229
|
|
|
$index = strrpos($fullClassName, '.'); |
|
230
|
|
|
$this->setPackage(substr($fullClassName, 0, $index)); |
|
231
|
|
|
$this->setClassName(substr($fullClassName, $index + 1)); |
|
232
|
|
|
} else { |
|
233
|
|
|
$this->setPackage(self::DEFAULT_PACKAGE); |
|
234
|
|
|
$this->setClassName($fullClassName); |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* Set passed. |
|
240
|
|
|
* |
|
241
|
|
|
* @return Test |
|
242
|
|
|
*/ |
|
243
|
|
View Code Duplication |
public function setpassed() |
|
|
|
|
|
|
244
|
|
|
{ |
|
245
|
|
|
$this->passed = 1; |
|
246
|
|
|
$this->failed = 0; |
|
247
|
|
|
$this->errored = 0; |
|
248
|
|
|
$this->skipped = 0; |
|
249
|
|
|
|
|
250
|
|
|
return $this; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Get passed. |
|
255
|
|
|
* |
|
256
|
|
|
* @return int |
|
257
|
|
|
*/ |
|
258
|
|
|
public function getPassed() |
|
259
|
|
|
{ |
|
260
|
|
|
return $this->passed; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* Set failed. |
|
265
|
|
|
* |
|
266
|
|
|
* @return Test |
|
267
|
|
|
*/ |
|
268
|
|
View Code Duplication |
public function setFailed() |
|
|
|
|
|
|
269
|
|
|
{ |
|
270
|
|
|
$this->passed = 0; |
|
271
|
|
|
$this->failed = 1; |
|
272
|
|
|
$this->errored = 0; |
|
273
|
|
|
$this->skipped = 0; |
|
274
|
|
|
|
|
275
|
|
|
return $this; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
/** |
|
279
|
|
|
* Get failed. |
|
280
|
|
|
* |
|
281
|
|
|
* @return int |
|
282
|
|
|
*/ |
|
283
|
|
|
public function getFailed() |
|
284
|
|
|
{ |
|
285
|
|
|
return $this->failed; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* Set errored. |
|
290
|
|
|
* |
|
291
|
|
|
* @return Test |
|
292
|
|
|
*/ |
|
293
|
|
View Code Duplication |
public function setErrored() |
|
|
|
|
|
|
294
|
|
|
{ |
|
295
|
|
|
$this->passed = 0; |
|
296
|
|
|
$this->failed = 0; |
|
297
|
|
|
$this->errored = 1; |
|
298
|
|
|
$this->skipped = 0; |
|
299
|
|
|
|
|
300
|
|
|
return $this; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* Get errored. |
|
305
|
|
|
* |
|
306
|
|
|
* @return int |
|
307
|
|
|
*/ |
|
308
|
|
|
public function getErrored() |
|
309
|
|
|
{ |
|
310
|
|
|
return $this->errored; |
|
311
|
|
|
} |
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* Set skipped. |
|
315
|
|
|
* |
|
316
|
|
|
* @return Test |
|
317
|
|
|
*/ |
|
318
|
|
View Code Duplication |
public function setSkipped() |
|
|
|
|
|
|
319
|
|
|
{ |
|
320
|
|
|
$this->passed = 0; |
|
321
|
|
|
$this->failed = 0; |
|
322
|
|
|
$this->errored = 0; |
|
323
|
|
|
$this->skipped = 1; |
|
324
|
|
|
|
|
325
|
|
|
return $this; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Get skipped. |
|
330
|
|
|
* |
|
331
|
|
|
* @return int |
|
332
|
|
|
*/ |
|
333
|
|
|
public function getSkipped() |
|
334
|
|
|
{ |
|
335
|
|
|
return $this->skipped; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* Set status. |
|
340
|
|
|
* |
|
341
|
|
|
* @param int $status |
|
342
|
|
|
* |
|
343
|
|
|
* @return Test |
|
344
|
|
|
*/ |
|
345
|
|
|
public function setStatus($status) |
|
346
|
|
|
{ |
|
347
|
|
|
switch ($status) { |
|
348
|
|
|
case Status::SUCCESS: |
|
349
|
|
|
$this->setPassed(); |
|
350
|
|
|
break; |
|
351
|
|
|
case Status::FAILED: |
|
352
|
|
|
$this->setFailed(); |
|
353
|
|
|
break; |
|
354
|
|
|
case Status::ERROR: |
|
355
|
|
|
$this->setErrored(); |
|
356
|
|
|
break; |
|
357
|
|
|
case Status::SKIPPED: |
|
358
|
|
|
$this->setSkipped(); |
|
359
|
|
|
break; |
|
360
|
|
|
} |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Get status. |
|
365
|
|
|
* |
|
366
|
|
|
* @return int |
|
367
|
|
|
*/ |
|
368
|
|
|
public function getStatus() |
|
369
|
|
|
{ |
|
370
|
|
|
if ($this->passed > 0) { |
|
371
|
|
|
return Status::SUCCESS; |
|
372
|
|
|
} elseif ($this->failed > 0) { |
|
373
|
|
|
return Status::FAILED; |
|
374
|
|
|
} elseif ($this->skipped > 0) { |
|
375
|
|
|
return Status::SKIPPED; |
|
376
|
|
|
} else { |
|
377
|
|
|
return Status::ERROR; |
|
378
|
|
|
} |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
/** |
|
382
|
|
|
* Get label of status. |
|
383
|
|
|
* |
|
384
|
|
|
* @return string |
|
385
|
|
|
*/ |
|
386
|
|
|
public function getLabelStatus() |
|
387
|
|
|
{ |
|
388
|
|
|
return Status::getLabel($this->getStatus()); |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* Set duration. |
|
393
|
|
|
* |
|
394
|
|
|
* @param float $duration |
|
395
|
|
|
* |
|
396
|
|
|
* @return Suite |
|
397
|
|
|
*/ |
|
398
|
|
|
public function setDuration($duration) |
|
399
|
|
|
{ |
|
400
|
|
|
$this->duration = $duration; |
|
401
|
|
|
|
|
402
|
|
|
return $this; |
|
|
|
|
|
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
/** |
|
406
|
|
|
* Get duration. |
|
407
|
|
|
* |
|
408
|
|
|
* @return float |
|
409
|
|
|
*/ |
|
410
|
|
|
public function getDuration() |
|
411
|
|
|
{ |
|
412
|
|
|
return $this->duration; |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* Set system out message. |
|
417
|
|
|
* |
|
418
|
|
|
* @param string $systemOut |
|
419
|
|
|
* |
|
420
|
|
|
* @return Test |
|
421
|
|
|
*/ |
|
422
|
|
|
public function setSystemOut($systemOut) |
|
423
|
|
|
{ |
|
424
|
|
|
$this->systemOut = $systemOut; |
|
425
|
|
|
|
|
426
|
|
|
return $this; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
/** |
|
430
|
|
|
* Get system out message. |
|
431
|
|
|
* |
|
432
|
|
|
* @return string |
|
433
|
|
|
*/ |
|
434
|
|
|
public function getSystemOut() |
|
435
|
|
|
{ |
|
436
|
|
|
return $this->systemOut; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* Set system error message. |
|
441
|
|
|
* |
|
442
|
|
|
* @param string $systemErr |
|
443
|
|
|
* |
|
444
|
|
|
* @return Test |
|
445
|
|
|
*/ |
|
446
|
|
|
public function setSystemErr($systemErr) |
|
447
|
|
|
{ |
|
448
|
|
|
$this->systemErr = $systemErr; |
|
449
|
|
|
|
|
450
|
|
|
return $this; |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* Get system error message. |
|
455
|
|
|
* |
|
456
|
|
|
* @return string |
|
457
|
|
|
*/ |
|
458
|
|
|
public function getSystemErr() |
|
459
|
|
|
{ |
|
460
|
|
|
return $this->systemErr; |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* Set order. |
|
465
|
|
|
* |
|
466
|
|
|
* @param int $position The order. |
|
467
|
|
|
* |
|
468
|
|
|
* @return Suite |
|
469
|
|
|
*/ |
|
470
|
|
|
public function setPosition($position) |
|
471
|
|
|
{ |
|
472
|
|
|
$this->position = $position; |
|
473
|
|
|
|
|
474
|
|
|
return $this; |
|
|
|
|
|
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* Get position. |
|
479
|
|
|
* |
|
480
|
|
|
* @return int |
|
481
|
|
|
*/ |
|
482
|
|
|
public function getPosition() |
|
483
|
|
|
{ |
|
484
|
|
|
return $this->position; |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
/** |
|
488
|
|
|
* Get reference id. |
|
489
|
|
|
* |
|
490
|
|
|
* @return int |
|
491
|
|
|
*/ |
|
492
|
|
|
public function getRefId() |
|
493
|
|
|
{ |
|
494
|
|
|
return $this->position + 1; |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
/** |
|
498
|
|
|
* Set suite. |
|
499
|
|
|
* |
|
500
|
|
|
* @param Suite $suite |
|
501
|
|
|
* |
|
502
|
|
|
* @return Suite |
|
503
|
|
|
*/ |
|
504
|
|
|
public function setSuite($suite) |
|
505
|
|
|
{ |
|
506
|
|
|
$this->suite = $suite; |
|
507
|
|
|
|
|
508
|
|
|
return $this; |
|
|
|
|
|
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
/** |
|
512
|
|
|
* Get suite. |
|
513
|
|
|
* |
|
514
|
|
|
* @return Suite |
|
515
|
|
|
*/ |
|
516
|
|
|
public function getSuite() |
|
517
|
|
|
{ |
|
518
|
|
|
return $this->suite; |
|
519
|
|
|
} |
|
520
|
|
|
} |
|
521
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.