• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / PHPUnit-Polyfills / 13226989791

09 Feb 2025 03:13PM UTC coverage: 98.331%. Remained the same
13226989791

Pull #247

github

web-flow
Merge acc65568e into a4f58ea08
Pull Request #247: Composer/GH Actions: allow for PHPUnit 12.x and make the tests cross-version compatible

589 of 599 relevant lines covered (98.33%)

143.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php
1
<?php
2

3
namespace Yoast\PHPUnitPolyfills\TestListeners;
4

5
use PHPUnit\Framework\AssertionFailedError;
6
use PHPUnit\Framework\Test;
7
use PHPUnit\Framework\TestSuite;
8
use PHPUnit\Framework\Warning;
9
use Throwable;
10

11
/**
12
 * Basic TestListener implementation for use with PHPUnit >= 7.x.
13
 *
14
 * This TestListener trait uses renamed (snakecase) methods for all standard methods in
15
 * a TestListener to get round the method signature changes in various PHPUnit versions.
16
 *
17
 * When using this TestListener trait, the snake_case method names need to be used to implement
18
 * the listener functionality.
19
 *
20
 * @since 0.2.0
21
 */
22
trait TestListenerDefaultImplementation {
23

24
        use TestListenerSnakeCaseMethods;
25

26
        /**
27
         * An error occurred.
28
         *
29
         * @param Test      $test Test object.
30
         * @param Throwable $t    Instance of the error encountered.
31
         * @param float     $time Execution time of this test.
32
         *
33
         * @return void
34
         */
35
        public function addError( Test $test, Throwable $t, float $time ): void {
20✔
36
                $this->add_error( $test, $t, $time );
20✔
37
        }
11✔
38

39
        /**
40
         * A warning occurred.
41
         *
42
         * This method is only functional in PHPUnit 6.0 and above.
43
         *
44
         * @param Test    $test Test object.
45
         * @param Warning $e    Instance of the warning encountered.
46
         * @param float   $time Execution time of this test.
47
         *
48
         * @return void
49
         */
50
        public function addWarning( Test $test, Warning $e, float $time ): void {
20✔
51
                $this->add_warning( $test, $e, $time );
20✔
52
        }
11✔
53

54
        /**
55
         * A failure occurred.
56
         *
57
         * @param Test                 $test Test object.
58
         * @param AssertionFailedError $e    Instance of the assertion failure exception encountered.
59
         * @param float                $time Execution time of this test.
60
         *
61
         * @return void
62
         */
63
        public function addFailure( Test $test, AssertionFailedError $e, float $time ): void {
20✔
64
                $this->add_failure( $test, $e, $time );
20✔
65
        }
11✔
66

67
        /**
68
         * Incomplete test.
69
         *
70
         * @param Test      $test Test object.
71
         * @param Throwable $t    Instance of the incomplete test exception.
72
         * @param float     $time Execution time of this test.
73
         *
74
         * @return void
75
         */
76
        public function addIncompleteTest( Test $test, Throwable $t, float $time ): void {
20✔
77
                $this->add_incomplete_test( $test, $t, $time );
20✔
78
        }
11✔
79

80
        /**
81
         * Risky test.
82
         *
83
         * @param Test      $test Test object.
84
         * @param Throwable $t    Instance of the risky test exception.
85
         * @param float     $time Execution time of this test.
86
         *
87
         * @return void
88
         */
89
        public function addRiskyTest( Test $test, Throwable $t, float $time ): void {
20✔
90
                $this->add_risky_test( $test, $t, $time );
20✔
91
        }
11✔
92

93
        /**
94
         * Skipped test.
95
         *
96
         * @param Test      $test Test object.
97
         * @param Throwable $t    Instance of the skipped test exception.
98
         * @param float     $time Execution time of this test.
99
         *
100
         * @return void
101
         */
102
        public function addSkippedTest( Test $test, Throwable $t, float $time ): void {
20✔
103
                $this->add_skipped_test( $test, $t, $time );
20✔
104
        }
11✔
105

106
        /**
107
         * A test suite started.
108
         *
109
         * @param TestSuite $suite Test suite object.
110
         *
111
         * @return void
112
         */
113
        public function startTestSuite( TestSuite $suite ): void {
×
114
                $this->start_test_suite( $suite );
×
115
        }
116

117
        /**
118
         * A test suite ended.
119
         *
120
         * @param TestSuite $suite Test suite object.
121
         *
122
         * @return void
123
         */
124
        public function endTestSuite( TestSuite $suite ): void {
×
125
                $this->end_test_suite( $suite );
×
126
        }
127

128
        /**
129
         * A test started.
130
         *
131
         * @param Test $test Test object.
132
         *
133
         * @return void
134
         */
135
        public function startTest( Test $test ): void {
140✔
136
                $this->start_test( $test );
140✔
137
        }
77✔
138

139
        /**
140
         * A test ended.
141
         *
142
         * @param Test  $test Test object.
143
         * @param float $time Execution time of this test.
144
         *
145
         * @return void
146
         */
147
        public function endTest( Test $test, float $time ): void {
140✔
148
                $this->end_test( $test, $time );
140✔
149
        }
77✔
150
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc