1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Paraunit\Configuration\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Paraunit\TestResult\TestResultContainer; |
6
|
|
|
use Paraunit\TestResult\TestResultFactory; |
7
|
|
|
use Paraunit\TestResult\TestResultFormat; |
8
|
|
|
use Paraunit\TestResult\TestResultList; |
9
|
|
|
use Paraunit\TestResult\TestResultWithSymbolFormat; |
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
11
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
12
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
13
|
|
|
|
14
|
|
|
class TestResultDefinition |
15
|
|
|
{ |
16
|
63 |
|
public function configure(ContainerBuilder $container) |
17
|
|
|
{ |
18
|
63 |
|
$container->setDefinition(TestResultFactory::class, new Definition(TestResultFactory::class)); |
19
|
63 |
|
$this->configureTestResultContainer($container); |
20
|
|
|
} |
21
|
|
|
|
22
|
63 |
|
private function configureTestResultContainer(ContainerBuilder $container) |
23
|
|
|
{ |
24
|
63 |
|
$testResultList = new Definition(TestResultList::class); |
25
|
|
|
|
26
|
63 |
|
foreach ($this->getFormatDefinitions() as $name => $format) { |
27
|
63 |
|
$formatName = sprintf('paraunit.test_result.%s_format', $name); |
28
|
63 |
|
$testResultContainerName = sprintf('paraunit.test_result.%s_container', $name); |
29
|
|
|
|
30
|
63 |
|
$container->setDefinition($formatName, $format); |
31
|
63 |
|
$container->setDefinition($testResultContainerName, new Definition(TestResultContainer::class, [ |
32
|
63 |
|
new Reference($formatName), |
33
|
|
|
])); |
34
|
|
|
|
35
|
63 |
|
$testResultList->addMethodCall('addContainer', [new Reference($testResultContainerName)]); |
36
|
|
|
} |
37
|
|
|
|
38
|
63 |
|
$container->setDefinition(TestResultList::class, $testResultList); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return Definition[] |
43
|
|
|
*/ |
44
|
63 |
|
private function getFormatDefinitions(): array |
45
|
|
|
{ |
46
|
|
|
return [ |
47
|
63 |
|
'unknown' => new Definition(TestResultWithSymbolFormat::class, [ |
48
|
63 |
|
'?', |
49
|
|
|
'unknown', |
50
|
|
|
'unknown results (log parsing failed)', |
51
|
|
|
]), |
52
|
63 |
|
'abnormal_terminated' => new Definition(TestResultWithSymbolFormat::class, [ |
53
|
63 |
|
'X', |
54
|
|
|
'abnormal', |
55
|
|
|
'abnormal terminations (fatal errors, segfaults)', |
56
|
|
|
]), |
57
|
63 |
|
'coverage_failure' => new Definition(TestResultFormat::class, [ |
58
|
63 |
|
'error', |
59
|
|
|
'coverage not fetched', |
60
|
|
|
]), |
61
|
63 |
|
'error' => new Definition(TestResultWithSymbolFormat::class, [ |
62
|
63 |
|
'E', |
63
|
|
|
'error', |
64
|
|
|
'errors', |
65
|
|
|
]), |
66
|
63 |
|
'failure' => new Definition(TestResultWithSymbolFormat::class, [ |
67
|
63 |
|
'F', |
68
|
|
|
'fail', |
69
|
|
|
'failures', |
70
|
|
|
]), |
71
|
63 |
|
'warning' => new Definition(TestResultWithSymbolFormat::class, [ |
72
|
63 |
|
'W', |
73
|
|
|
'warning', |
74
|
|
|
'warnings', |
75
|
|
|
]), |
76
|
63 |
|
'deprecation' => new Definition(TestResultFormat::class, [ |
77
|
63 |
|
'fail', |
78
|
|
|
'deprecation warnings', |
79
|
|
|
]), |
80
|
63 |
|
'no_test_executed' => new Definition(TestResultFormat::class, [ |
81
|
63 |
|
'warning', |
82
|
|
|
'no tests executed', |
83
|
|
|
]), |
84
|
63 |
|
'risky' => new Definition(TestResultWithSymbolFormat::class, [ |
85
|
63 |
|
'R', |
86
|
|
|
'warning', |
87
|
|
|
'risky outcome', |
88
|
|
|
]), |
89
|
63 |
|
'skipped' => new Definition(TestResultWithSymbolFormat::class, [ |
90
|
63 |
|
'S', |
91
|
|
|
'skip', |
92
|
|
|
'skipped outcome', |
93
|
|
|
false, |
94
|
|
|
]), |
95
|
63 |
|
'incomplete' => new Definition(TestResultWithSymbolFormat::class, [ |
96
|
63 |
|
'I', |
97
|
|
|
'incomplete', |
98
|
|
|
'incomplete outcome', |
99
|
|
|
false, |
100
|
|
|
]), |
101
|
63 |
|
'retry' => new Definition(TestResultWithSymbolFormat::class, [ |
102
|
63 |
|
'A', |
103
|
|
|
'ok', |
104
|
|
|
'RETRIED', |
105
|
|
|
false, |
106
|
|
|
]), |
107
|
63 |
|
'pass' => new Definition(TestResultWithSymbolFormat::class, [ |
108
|
63 |
|
'.', |
109
|
|
|
'ok', |
110
|
|
|
'PASSED', |
111
|
|
|
false, |
112
|
|
|
false, |
113
|
|
|
]), |
114
|
|
|
]; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|