Completed
Pull Request — feature/phpunitv6 (#11)
by Yo
04:53
created

DelegatingListener::getListenerList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Yoanm\PhpUnitExtended\Listener;
3
4
use PHPUnit\Framework\AssertionFailedError;
5
use PHPUnit\Framework\Test;
6
use PHPUnit\Framework\TestListener;
7
use PHPUnit\Framework\TestSuite;
8
use PHPUnit\Framework\Warning;
9
10
/**
11
 * Simple listener delegator
12 10
 */
13
class DelegatingListener implements TestListener
14 10
{
15 10
    /** TestListener[] */
16
    private $listenerList = [];
17
18
    /**
19
     * {@inheritdoc}
20 1
     */
21
    public function addListener(TestListener $listener)
22 1
    {
23
        $this->listenerList[] = $listener;
24
    }
25 1
26
    /**
27 1
     * @return TestListener[]
28 1
     */
29
    public function getListenerList()
30 1
    {
31
        return $this->listenerList;
32 1
    }
33
34 1
    /**
35 1
     * {@inheritdoc}
36
     */
37 1
    public function addError(Test $test, \Throwable $e, float $time)
38
    {
39 1
        foreach ($this->listenerList as $listener) {
40
            $listener->addError($test, $e, $time);
41 1
        }
42 1
    }
43
44 1
    /**
45
     * {@inheritdoc}
46 1
     */
47
    public function addWarning(Test $test, Warning $e, float $time)
48 1
    {
49 1
        foreach ($this->listenerList as $listener) {
50
            $listener->addWarning($test, $e, $time);
51 1
        }
52
    }
53 1
54
    /**
55 1
     * {@inheritdoc}
56 1
     */
57
    public function addFailure(Test $test, AssertionFailedError $e, float $time)
58 1
    {
59
        foreach ($this->listenerList as $listener) {
60 1
            $listener->addFailure($test, $e, $time);
61
        }
62 1
    }
63 1
64
    /**
65 1
     * {@inheritdoc}
66
     */
67 1
    public function addIncompleteTest(Test $test, \Throwable $e, float $time)
68
    {
69 1
        foreach ($this->listenerList as $listener) {
70 1
            $listener->addIncompleteTest($test, $e, $time);
71
        }
72 1
    }
73
74 1
    /**
75
     * {@inheritdoc}
76 1
     */
77 1
    public function addRiskyTest(Test $test, \Throwable $e, float $time)
78
    {
79 1
        foreach ($this->listenerList as $listener) {
80
            $listener->addRiskyTest($test, $e, $time);
81 1
        }
82
    }
83 1
84 1
    /**
85
     * {@inheritdoc}
86 1
     */
87
    public function addSkippedTest(Test $test, \Throwable $e, float $time)
88
    {
89
        foreach ($this->listenerList as $listener) {
90
            $listener->addSkippedTest($test, $e, $time);
91
        }
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function startTestSuite(TestSuite $suite)
98
    {
99
        foreach ($this->listenerList as $listener) {
100
            $listener->startTestSuite($suite);
101
        }
102
    }
103
104
    /**
105
     * {@inheritdoc}
106
     */
107
    public function endTestSuite(TestSuite $suite)
108
    {
109
        foreach ($this->listenerList as $listener) {
110
            $listener->endTestSuite($suite);
111
        }
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function startTest(Test $test)
118
    {
119
        foreach ($this->listenerList as $listener) {
120
            $listener->startTest($test);
121
        }
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function endTest(Test $test, $time)
128
    {
129
        foreach ($this->listenerList as $listener) {
130
            $listener->endTest($test, $time);
131
        }
132
    }
133
}
134