|
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
|
|
|
declare(strict_types=1); |
|
21
|
|
|
|
|
22
|
|
|
namespace App\DataFixtures\ORM; |
|
23
|
|
|
|
|
24
|
|
|
use App\Entity\Test; |
|
25
|
|
|
use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface; |
|
26
|
|
|
use Doctrine\Common\DataFixtures\AbstractFixture; |
|
27
|
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; |
|
28
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Test fixtures load class. |
|
32
|
|
|
* |
|
33
|
|
|
* @category ci-report app |
|
34
|
|
|
* |
|
35
|
|
|
* @author Francois-Xavier Soubirou <[email protected]> |
|
36
|
|
|
* @copyright 2017 Francois-Xavier Soubirou |
|
37
|
|
|
* @license http://www.gnu.org/licenses/ GPLv3 |
|
38
|
|
|
* |
|
39
|
|
|
* @see https://www.ci-report.io |
|
40
|
|
|
*/ |
|
41
|
|
|
class Tests extends AbstractFixture implements OrderedFixtureInterface, ORMFixtureInterface |
|
42
|
|
|
{ |
|
43
|
|
|
/** |
|
44
|
|
|
* Load data fixtures with the passed EntityManager. |
|
45
|
|
|
* |
|
46
|
|
|
* @param ObjectManager $manager The entity manager |
|
47
|
|
|
*/ |
|
48
|
|
|
public function load(ObjectManager $manager) |
|
49
|
|
|
{ |
|
50
|
|
|
$systemOut = <<<'EOT' |
|
51
|
|
|
System out message : |
|
52
|
|
|
- Out 1 |
|
53
|
|
|
- Out 2 |
|
54
|
|
|
EOT; |
|
55
|
|
|
$systemErr = <<<'EOT' |
|
56
|
|
|
System error message : |
|
57
|
|
|
- Error 1, |
|
58
|
|
|
- Error 2, |
|
59
|
|
|
- Error 3. |
|
60
|
|
|
EOT; |
|
61
|
|
|
$failureMsg = <<<'EOT' |
|
62
|
|
|
Type: Type of message |
|
63
|
|
|
|
|
64
|
|
|
Message: Message |
|
65
|
|
|
|
|
66
|
|
|
Details: Details of message ... |
|
67
|
|
|
EOT; |
|
68
|
|
|
$dataArray = array( |
|
69
|
|
|
array( |
|
70
|
|
|
'count' => '12', |
|
71
|
|
|
'fullClassName' => array( |
|
72
|
|
|
'className2', |
|
73
|
|
|
'className2', |
|
74
|
|
|
'className1', |
|
75
|
|
|
'className1', |
|
76
|
|
|
'className1', |
|
77
|
|
|
'package1.className1', |
|
78
|
|
|
'io.ci-report.className3', |
|
79
|
|
|
'io.ci-report.className3', |
|
80
|
|
|
'io.ci-report.className3', |
|
81
|
|
|
'io.ci-report.className4', |
|
82
|
|
|
'io.ci-report.package.className4', |
|
83
|
|
|
'io.ci-report.package.className5', |
|
84
|
|
|
), |
|
85
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
86
|
|
|
'duration' => 1, |
|
87
|
|
|
'systemOut' => $systemOut, |
|
88
|
|
|
'systemErr' => $systemErr, |
|
89
|
|
|
'failureMsg' => $failureMsg, |
|
90
|
|
|
'suite' => 'p1c1s1-suite', |
|
91
|
|
|
), |
|
92
|
|
|
array( |
|
93
|
|
|
'count' => '13', |
|
94
|
|
|
'fullClassName' => array( |
|
95
|
|
|
'className2', |
|
96
|
|
|
'className2', |
|
97
|
|
|
'className1', |
|
98
|
|
|
'className1', |
|
99
|
|
|
'className1', |
|
100
|
|
|
'package1.className1', |
|
101
|
|
|
'io.ci-report.className3', |
|
102
|
|
|
'io.ci-report.className3', |
|
103
|
|
|
'io.ci-report.className3', |
|
104
|
|
|
'io.ci-report.className4', |
|
105
|
|
|
'io.ci-report.package.className4', |
|
106
|
|
|
'io.ci-report.package.className5', |
|
107
|
|
|
'io.ci-report.package.className6', |
|
108
|
|
|
), |
|
109
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
110
|
|
|
'duration' => 1, |
|
111
|
|
|
'systemOut' => $systemOut, |
|
112
|
|
|
'systemErr' => $systemErr, |
|
113
|
|
|
'failureMsg' => $failureMsg, |
|
114
|
|
|
'suite' => 'p1c1s2-suite', |
|
115
|
|
|
), |
|
116
|
|
|
array( |
|
117
|
|
|
'count' => '13', |
|
118
|
|
|
'fullClassName' => array( |
|
119
|
|
|
'className2', |
|
120
|
|
|
'className2', |
|
121
|
|
|
'className1', |
|
122
|
|
|
'className1', |
|
123
|
|
|
'className1', |
|
124
|
|
|
'package1.className1', |
|
125
|
|
|
'io.ci-report.className3', |
|
126
|
|
|
'io.ci-report.className3', |
|
127
|
|
|
'io.ci-report.className3', |
|
128
|
|
|
'io.ci-report.className4', |
|
129
|
|
|
'io.ci-report.package.className4', |
|
130
|
|
|
'io.ci-report.package.className5', |
|
131
|
|
|
'io.ci-report.package.className6', |
|
132
|
|
|
), |
|
133
|
|
|
'status' => array(Test::PASSED, Test::ERRORED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
134
|
|
|
'duration' => 1, |
|
135
|
|
|
'systemOut' => $systemOut, |
|
136
|
|
|
'systemErr' => $systemErr, |
|
137
|
|
|
'failureMsg' => $failureMsg, |
|
138
|
|
|
'suite' => 'p1c2s1-suite', |
|
139
|
|
|
), |
|
140
|
|
|
array( |
|
141
|
|
|
'count' => '13', |
|
142
|
|
|
'fullClassName' => array( |
|
143
|
|
|
'className2', |
|
144
|
|
|
'className2', |
|
145
|
|
|
'className1', |
|
146
|
|
|
'className1', |
|
147
|
|
|
'className1', |
|
148
|
|
|
'package1.className1', |
|
149
|
|
|
'io.ci-report.className3', |
|
150
|
|
|
'io.ci-report.className3', |
|
151
|
|
|
'io.ci-report.className3', |
|
152
|
|
|
'io.ci-report.className4', |
|
153
|
|
|
'io.ci-report.package.className4', |
|
154
|
|
|
'io.ci-report.package.className5', |
|
155
|
|
|
'io.ci-report.package.className6', |
|
156
|
|
|
), |
|
157
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
158
|
|
|
'duration' => 1, |
|
159
|
|
|
'systemOut' => $systemOut, |
|
160
|
|
|
'systemErr' => $systemErr, |
|
161
|
|
|
'failureMsg' => $failureMsg, |
|
162
|
|
|
'suite' => 'p1c2s2-suite', |
|
163
|
|
|
), |
|
164
|
|
|
array( |
|
165
|
|
|
'count' => '13', |
|
166
|
|
|
'fullClassName' => array( |
|
167
|
|
|
'className2', |
|
168
|
|
|
'className2', |
|
169
|
|
|
'className1', |
|
170
|
|
|
'className1', |
|
171
|
|
|
'className1', |
|
172
|
|
|
'package1.className1', |
|
173
|
|
|
'io.ci-report.className3', |
|
174
|
|
|
'io.ci-report.className3', |
|
175
|
|
|
'io.ci-report.className3', |
|
176
|
|
|
'io.ci-report.className4', |
|
177
|
|
|
'io.ci-report.package.className4', |
|
178
|
|
|
'io.ci-report.package.className5', |
|
179
|
|
|
'io.ci-report.package.className6', |
|
180
|
|
|
), |
|
181
|
|
|
'status' => array(Test::PASSED, Test::FAILED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
182
|
|
|
'duration' => 1, |
|
183
|
|
|
'systemOut' => $systemOut, |
|
184
|
|
|
'systemErr' => $systemErr, |
|
185
|
|
|
'failureMsg' => $failureMsg, |
|
186
|
|
|
'suite' => 'p1c3s1-suite', |
|
187
|
|
|
), |
|
188
|
|
|
array( |
|
189
|
|
|
'count' => '13', |
|
190
|
|
|
'fullClassName' => array( |
|
191
|
|
|
'className2', |
|
192
|
|
|
'className2', |
|
193
|
|
|
'className1', |
|
194
|
|
|
'className1', |
|
195
|
|
|
'className1', |
|
196
|
|
|
'package1.className1', |
|
197
|
|
|
'io.ci-report.className3', |
|
198
|
|
|
'io.ci-report.className3', |
|
199
|
|
|
'io.ci-report.className3', |
|
200
|
|
|
'io.ci-report.className4', |
|
201
|
|
|
'io.ci-report.package.className4', |
|
202
|
|
|
'io.ci-report.package.className5', |
|
203
|
|
|
'io.ci-report.package.className6', |
|
204
|
|
|
), |
|
205
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
206
|
|
|
'duration' => 1, |
|
207
|
|
|
'systemOut' => $systemOut, |
|
208
|
|
|
'systemErr' => $systemErr, |
|
209
|
|
|
'failureMsg' => $failureMsg, |
|
210
|
|
|
'suite' => 'p1c3s2-suite', |
|
211
|
|
|
), |
|
212
|
|
|
array( |
|
213
|
|
|
'count' => '13', |
|
214
|
|
|
'fullClassName' => array( |
|
215
|
|
|
'className2', |
|
216
|
|
|
'className2', |
|
217
|
|
|
'className1', |
|
218
|
|
|
'className1', |
|
219
|
|
|
'className1', |
|
220
|
|
|
'package1.className1', |
|
221
|
|
|
'io.ci-report.className3', |
|
222
|
|
|
'io.ci-report.className3', |
|
223
|
|
|
'io.ci-report.className3', |
|
224
|
|
|
'io.ci-report.className4', |
|
225
|
|
|
'io.ci-report.package.className4', |
|
226
|
|
|
'io.ci-report.package.className5', |
|
227
|
|
|
'io.ci-report.package.className6', |
|
228
|
|
|
), |
|
229
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
230
|
|
|
'duration' => 1, |
|
231
|
|
|
'systemOut' => '', |
|
232
|
|
|
'systemErr' => '', |
|
233
|
|
|
'failureMsg' => '', |
|
234
|
|
|
'suite' => 'p1c4s1-suite', |
|
235
|
|
|
), |
|
236
|
|
|
array( |
|
237
|
|
|
'count' => '13', |
|
238
|
|
|
'fullClassName' => array( |
|
239
|
|
|
'className2', |
|
240
|
|
|
'className2', |
|
241
|
|
|
'className1', |
|
242
|
|
|
'className1', |
|
243
|
|
|
'className1', |
|
244
|
|
|
'package1.className1', |
|
245
|
|
|
'io.ci-report.className3', |
|
246
|
|
|
'io.ci-report.className3', |
|
247
|
|
|
'io.ci-report.className3', |
|
248
|
|
|
'io.ci-report.className4', |
|
249
|
|
|
'io.ci-report.package.className4', |
|
250
|
|
|
'io.ci-report.package.className5', |
|
251
|
|
|
'io.ci-report.package.className6', |
|
252
|
|
|
), |
|
253
|
|
|
'status' => array(Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED, Test::PASSED), |
|
254
|
|
|
'duration' => 1, |
|
255
|
|
|
'systemOut' => $systemOut, |
|
256
|
|
|
'systemErr' => $systemErr, |
|
257
|
|
|
'failureMsg' => $failureMsg, |
|
258
|
|
|
'suite' => 'p1c4s2-suite', |
|
259
|
|
|
), |
|
260
|
|
|
$this->fillInTestArray(79, 21, 0, 0, 'p2c1s1-suite'), |
|
261
|
|
|
$this->fillInTestArray(80, 20, 0, 0, 'p2c2s1-suite'), |
|
262
|
|
|
$this->fillInTestArray(95, 4, 0, 1, 'p2c3s1-suite'), |
|
263
|
|
|
$this->fillInTestArray(95, 5, 0, 0, 'p3c1s1-suite'), |
|
264
|
|
|
$this->fillInTestArray(79, 21, 0, 0, 'p3c2s1-suite'), |
|
265
|
|
|
$this->fillInTestArray(80, 20, 0, 0, 'p3c3s1-suite'), |
|
266
|
|
|
$this->fillInTestArray(95, 0, 5, 0, 'p4c1s1-suite'), |
|
267
|
|
|
$this->fillInTestArray(80, 0, 20, 0, 'p4c2s1-suite'), |
|
268
|
|
|
$this->fillInTestArray(79, 0, 21, 0, 'p4c3s1-suite'), |
|
269
|
|
|
$this->fillInTestArray(79, 0, 0, 21, 'p5c1s1-suite'), |
|
270
|
|
|
$this->fillInTestArray(80, 0, 0, 20, 'p5c2s1-suite'), |
|
271
|
|
|
$this->fillInTestArray(95, 0, 0, 5, 'p5c3s1-suite'), |
|
272
|
|
|
$this->fillInTestArray(50, 0, 0, 0, 'p5c4s1-suite'), |
|
273
|
|
|
); |
|
274
|
|
|
|
|
275
|
|
|
$objectList = array(); |
|
276
|
|
|
foreach ($dataArray as $i => $data) { |
|
277
|
|
|
for ($j = 0; $j < $data['count']; ++$j) { |
|
278
|
|
|
$k = $i.$j; |
|
279
|
|
|
$objectList[$k] = new Test($this->getReference($data['suite'])); |
|
280
|
|
|
$objectList[$k]->setName('Test '.$j.' in '.$data['suite']); |
|
281
|
|
|
$objectList[$k]->setFullClassName($data['fullClassName'][$j]); |
|
282
|
|
|
$objectList[$k]->setStatus($data['status'][$j]); |
|
283
|
|
|
$objectList[$k]->setDuration($data['duration'] + 0.1 * $j); |
|
284
|
|
|
if ('' !== $data['systemOut']) { |
|
285
|
|
|
$objectList[$k]->setSystemout($k.' : '.$data['systemOut']); |
|
286
|
|
|
} |
|
287
|
|
|
if ('' !== $data['systemErr']) { |
|
288
|
|
|
$objectList[$k]->setSystemerr($k.' : '.$data['systemErr']); |
|
289
|
|
|
} |
|
290
|
|
|
if ('' !== $data['failureMsg']) { |
|
291
|
|
|
$objectList[$k]->setFailuremsg($data['failureMsg']); |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
$manager->persist($objectList[$k]); |
|
295
|
|
|
} |
|
296
|
|
|
} |
|
297
|
|
|
$manager->flush(); |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Fill in array with default test values. |
|
302
|
|
|
* |
|
303
|
|
|
* @param int $passed Amount of passed tests. |
|
304
|
|
|
* @param int $failed Amount of failed tests. |
|
305
|
|
|
* @param int $errored Amount of errored tests. |
|
306
|
|
|
* @param int $skipped Amount of skipped tests. |
|
307
|
|
|
* @param string $suite Suite reference. |
|
308
|
|
|
* |
|
309
|
|
|
* @return array |
|
310
|
|
|
*/ |
|
311
|
|
|
public function fillInTestArray($passed, $failed, $errored, $skipped, $suite) |
|
312
|
|
|
{ |
|
313
|
|
|
$count = $passed + $failed + $errored + $skipped; |
|
314
|
|
|
|
|
315
|
|
|
$fillInArray = array(); |
|
316
|
|
|
|
|
317
|
|
|
$fillInArray['count'] = $count; |
|
318
|
|
|
$fillInArray['suite'] = $suite; |
|
319
|
|
|
|
|
320
|
|
|
$arrayFullClassName = array(); |
|
321
|
|
|
for ($i = 0; $i < $count; ++$i) { |
|
322
|
|
|
$index = $i % 10; |
|
323
|
|
|
$arrayFullClassName[] = 'io.ci-report.className'.$index; |
|
324
|
|
|
} |
|
325
|
|
|
$fillInArray['fullClassName'] = $arrayFullClassName; |
|
326
|
|
|
|
|
327
|
|
|
$arrayStatus = array(); |
|
328
|
|
|
for ($i = 0; $i < $passed; ++$i) { |
|
329
|
|
|
$arrayStatus[] = Test::PASSED; |
|
330
|
|
|
} |
|
331
|
|
|
for ($i = 0; $i < $failed; ++$i) { |
|
332
|
|
|
$arrayStatus[] = Test::FAILED; |
|
333
|
|
|
} |
|
334
|
|
|
for ($i = 0; $i < $errored; ++$i) { |
|
335
|
|
|
$arrayStatus[] = Test::ERRORED; |
|
336
|
|
|
} |
|
337
|
|
|
for ($i = 0; $i < $skipped; ++$i) { |
|
338
|
|
|
$arrayStatus[] = Test::SKIPPED; |
|
339
|
|
|
} |
|
340
|
|
|
$fillInArray['status'] = $arrayStatus; |
|
341
|
|
|
|
|
342
|
|
|
$fillInArray['duration'] = 1; |
|
343
|
|
|
$fillInArray['systemOut'] = 'systemOutMessage'; |
|
344
|
|
|
$fillInArray['systemErr'] = 'systemErrMessage'; |
|
345
|
|
|
$fillInArray['failureMsg'] = 'failureMessage'; |
|
346
|
|
|
|
|
347
|
|
|
return $fillInArray; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* Get the order of this fixture. |
|
352
|
|
|
* |
|
353
|
|
|
* @return int |
|
354
|
|
|
*/ |
|
355
|
|
|
public function getOrder(): int |
|
356
|
|
|
{ |
|
357
|
|
|
return 40; |
|
358
|
|
|
} |
|
359
|
|
|
} |
|
360
|
|
|
|