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

Yoast / PHPUnit-Polyfills / 10743602567

06 Sep 2024 06:43PM UTC coverage: 96.423%. First build
10743602567

push

github

jrfnl
Drop support for PHP < 7.0 [4]

In the original implementation of the `assertObjectEquals()` polyfill, the polyfill could not mirror the PHPUnit native implementation completely as that required support for return types, which was only added in PHP 7.0, while the polyfill was introduced in PHPUnit Polyfills 1.0, which still supported PHP 5.5.

So instead of checking whether the "comparator" method had a return type declared and verifying that this return type complied with the requirements set by PHPUnit, the polyfill originally checked whether the _returned value_ complied with the required type.

Now support for PHP < 7.0 is being dropped, the `assertObjectEquals()` polyfill can be updated to fix this implementation difference.

Includes unit tests for the changed functionality/new logic paths throwing exceptions.
Includes updated documentation in the README.

Refs:
* 38
* sebastianbergmann/phpunit 4707
* sebastianbergmann/phpunit 4467
* sebastianbergmann/phpunit 4707
* https://github.com/sebastianbergmann/phpunit/commit/1dba8c3a4
* https://github.com/sebastianbergmann/phpunit/commit/6099c5eef

28 of 29 new or added lines in 1 file covered. (96.55%)

620 of 643 relevant lines covered (96.42%)

124.33 hits per line

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

77.78
/src/TestListeners/TestListenerDefaultImplementationPHPUnitLte5.php
1
<?php
2

3
namespace Yoast\PHPUnitPolyfills\TestListeners;
4

5
use Exception;
6
use PHPUnit_Framework_AssertionFailedError;
7
use PHPUnit_Framework_Test;
8
use PHPUnit_Framework_TestSuite;
9
use PHPUnit_Framework_Warning;
10

11
/**
12
 * Basic TestListener implementation for use with PHPUnit 5.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
 * {@internal While in essence this trait is no different from the PHPUnit 6.x version, this
21
 * version is necessary as the class/interface name type declarations used in the PHPUnit 6.x
22
 * file are based on the namespaced names. As both the namespaced names as well as the
23
 * non-namespaced names exist in PHPUnit 5.7.21+, we cannot create class aliases to
24
 * get round the signature mismatch and need this trait using the old names instead.}
25
 */
26
trait TestListenerDefaultImplementation {
27

28
        use TestListenerSnakeCaseMethods;
29

30
        /**
31
         * An error occurred.
32
         *
33
         * @param PHPUnit_Framework_Test $test Test object.
34
         * @param Exception              $e    Instance of the error encountered.
35
         * @param float                  $time Execution time of this test.
36
         *
37
         * @return void
38
         */
39
        public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
3✔
40
                $this->add_error( $test, $e, $time );
3✔
41
        }
3✔
42

43
        /**
44
         * A warning occurred.
45
         *
46
         * This method is only functional in PHPUnit 6.0 and above.
47
         *
48
         * @param PHPUnit_Framework_Test    $test Test object.
49
         * @param PHPUnit_Framework_Warning $e    Instance of the warning encountered.
50
         * @param float                     $time Execution time of this test.
51
         *
52
         * @return void
53
         */
54
        public function addWarning( PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time ) {
3✔
55
                $this->add_warning( $test, $e, $time );
3✔
56
        }
3✔
57

58
        /**
59
         * A failure occurred.
60
         *
61
         * @param PHPUnit_Framework_Test                 $test Test object.
62
         * @param PHPUnit_Framework_AssertionFailedError $e    Instance of the assertion failure
63
         *                                                     exception encountered.
64
         * @param float                                  $time Execution time of this test.
65
         *
66
         * @return void
67
         */
68
        public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
3✔
69
                $this->add_failure( $test, $e, $time );
3✔
70
        }
3✔
71

72
        /**
73
         * Incomplete test.
74
         *
75
         * @param PHPUnit_Framework_Test $test Test object.
76
         * @param Exception              $e    Instance of the incomplete test exception.
77
         * @param float                  $time Execution time of this test.
78
         *
79
         * @return void
80
         */
81
        public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
3✔
82
                $this->add_incomplete_test( $test, $e, $time );
3✔
83
        }
3✔
84

85
        /**
86
         * Risky test.
87
         *
88
         * @param PHPUnit_Framework_Test $test Test object.
89
         * @param Exception              $e    Instance of the risky test exception.
90
         * @param float                  $time Execution time of this test.
91
         *
92
         * @return void
93
         */
94
        public function addRiskyTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
×
95
                $this->add_risky_test( $test, $e, $time );
×
96
        }
97

98
        /**
99
         * Skipped test.
100
         *
101
         * @param PHPUnit_Framework_Test $test Test object.
102
         * @param Exception              $e    Instance of the skipped test exception.
103
         * @param float                  $time Execution time of this test.
104
         *
105
         * @return void
106
         */
107
        public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
3✔
108
                $this->add_skipped_test( $test, $e, $time );
3✔
109
        }
3✔
110

111
        /**
112
         * A test suite started.
113
         *
114
         * @param PHPUnit_Framework_TestSuite $suite Test suite object.
115
         *
116
         * @return void
117
         */
118
        public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
×
119
                $this->start_test_suite( $suite );
×
120
        }
121

122
        /**
123
         * A test suite ended.
124
         *
125
         * @param PHPUnit_Framework_TestSuite $suite Test suite object.
126
         *
127
         * @return void
128
         */
129
        public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
×
130
                $this->end_test_suite( $suite );
×
131
        }
132

133
        /**
134
         * A test started.
135
         *
136
         * @param PHPUnit_Framework_Test $test Test object.
137
         *
138
         * @return void
139
         */
140
        public function startTest( PHPUnit_Framework_Test $test ) {
18✔
141
                $this->start_test( $test );
18✔
142
        }
18✔
143

144
        /**
145
         * A test ended.
146
         *
147
         * @param PHPUnit_Framework_Test $test Test object.
148
         * @param float                  $time Execution time of this test.
149
         *
150
         * @return void
151
         */
152
        public function endTest( PHPUnit_Framework_Test $test, $time ) {
18✔
153
                $this->end_test( $test, $time );
18✔
154
        }
18✔
155
}
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

© 2025 Coveralls, Inc