• 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

85.71
/src/TestListeners/TestListenerDefaultImplementationPHPUnit6.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 6.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
trait TestListenerDefaultImplementation {
21

22
        use TestListenerSnakeCaseMethods;
23

24
        /**
25
         * An error occurred.
26
         *
27
         * @param Test      $test Test object.
28
         * @param Exception $e    Instance of the error encountered.
29
         * @param float     $time Execution time of this test.
30
         *
31
         * @return void
32
         */
33
        public function addError( Test $test, Exception $e, $time ) {
3✔
34
                $this->add_error( $test, $e, $time );
3✔
35
        }
3✔
36

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

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

65
        /**
66
         * Incomplete test.
67
         *
68
         * @param Test      $test Test object.
69
         * @param Exception $e    Instance of the incomplete test exception.
70
         * @param float     $time Execution time of this test.
71
         *
72
         * @return void
73
         */
74
        public function addIncompleteTest( Test $test, Exception $e, $time ) {
3✔
75
                $this->add_incomplete_test( $test, $e, $time );
3✔
76
        }
3✔
77

78
        /**
79
         * Risky test.
80
         *
81
         * @param Test      $test Test object.
82
         * @param Exception $e    Instance of the risky test exception.
83
         * @param float     $time Execution time of this test.
84
         *
85
         * @return void
86
         */
87
        public function addRiskyTest( Test $test, Exception $e, $time ) {
3✔
88
                $this->add_risky_test( $test, $e, $time );
3✔
89
        }
3✔
90

91
        /**
92
         * Skipped test.
93
         *
94
         * @param Test      $test Test object.
95
         * @param Exception $e    Instance of the skipped test exception.
96
         * @param float     $time Execution time of this test.
97
         *
98
         * @return void
99
         */
100
        public function addSkippedTest( Test $test, Exception $e, $time ) {
3✔
101
                $this->add_skipped_test( $test, $e, $time );
3✔
102
        }
3✔
103

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

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

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

137
        /**
138
         * A test ended.
139
         *
140
         * @param Test  $test Test object.
141
         * @param float $time Execution time of this test.
142
         *
143
         * @return void
144
         */
145
        public function endTest( Test $test, $time ) {
21✔
146
                $this->end_test( $test, $time );
21✔
147
        }
21✔
148
}
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