Ticket #39822: 39822.3.patch
File 39822.3.patch, 11.7 KB (added by , 8 years ago) |
---|
-
tests/phpunit/includes/bootstrap.php
3 3 * Installs WordPress for running the tests and loads WordPress and the test libraries 4 4 */ 5 5 6 /** 7 * Migration fixer for PHPUnit 6 8 */ 9 if ( class_exists( 'PHPUnit\Runner\Version' ) ) { 10 require_once dirname( __FILE__ ) . '/phpunit6-compat.php'; 11 } 6 12 7 13 $config_file_path = dirname( dirname( __FILE__ ) ); 8 14 if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { -
tests/phpunit/includes/phpunit6-compat.php
1 <?php 2 3 if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) { 4 class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' ); 5 class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' ); 6 class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' ); 7 class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' ); 8 class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' ); 9 class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' ); 10 class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' ); 11 class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' ); 12 class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' ); 13 class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' ); 14 class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' ); 15 16 class PHPUnit_Util_Test extends PHPUnit\Util\Test { 17 public static function getTickets( $className, $methodName ) { 18 $annotations = self::parseTestMethodAnnotations( 19 $className, $methodName 20 ); 21 22 $tickets = array(); 23 24 if (isset($annotations['class']['ticket'])) { 25 $tickets = $annotations['class']['ticket']; 26 } 27 28 if (isset($annotations['method']['ticket'])) { 29 $tickets = array_merge($tickets, $annotations['method']['ticket']); 30 } 31 32 return array_unique($tickets); 33 } 34 } 35 } -
tests/phpunit/includes/testcase-ajax.php
200 200 if ( !empty( $buffer ) ) 201 201 $this->_last_response = $buffer; 202 202 } 203 204 /** 205 * PHPUnit 6 compatibility shim. 206 * 207 * @param mixed $exception 208 * @param string $message 209 * @param int|string $code 210 */ 211 protected function _setExpectedException( $exception, $message = '', $code = null ) { 212 if ( method_exists( $this, 'setExpectedException' ) ) { 213 $this->setExpectedException( $exception, $message, $code ); 214 } else { 215 $this->expectException( $exception ); 216 if ( '' !== $message ) { 217 $this->expectExceptionMessage( $message ); 218 } 219 if ( null !== $code ) { 220 $this->expectExceptionCode( $code ); 221 } 222 } 223 } 203 224 } -
tests/phpunit/tests/ajax/Compression.php
25 25 $_GET['test'] = 1; 26 26 27 27 // Make the request 28 $this-> setExpectedException( 'WPAjaxDieStopException', '0' );28 $this->_setExpectedException( 'WPAjaxDieStopException', '0' ); 29 29 $this->_handleAjax( 'wp-compression-test' ); 30 30 } 31 31 … … 118 118 $_SERVER['HTTP_ACCEPT_ENCODING'] = 'unknown'; 119 119 120 120 // Make the request 121 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );121 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 122 122 $this->_handleAjax( 'wp-compression-test' ); 123 123 } 124 124 -
tests/phpunit/tests/ajax/CustomizeMenus.php
54 54 55 55 if ( 'administrator' != $role ) { 56 56 // If we're not an admin, we should get a wp_die(-1). 57 $this-> setExpectedException( 'WPAjaxDieStopException' );57 $this->_setExpectedException( 'WPAjaxDieStopException' ); 58 58 } 59 59 60 60 wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); … … 429 429 430 430 if ( 'administrator' != $role ) { 431 431 // If we're not an admin, we should get a wp_die(-1). 432 $this-> setExpectedException( 'WPAjaxDieStopException' );432 $this->_setExpectedException( 'WPAjaxDieStopException' ); 433 433 } 434 434 435 435 wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); -
tests/phpunit/tests/ajax/DeleteComment.php
133 133 $_POST['_url'] = admin_url( 'edit-comments.php' ); 134 134 135 135 // Make the request 136 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );136 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 137 137 $this->_handleAjax( 'delete-comment' ); 138 138 } 139 139 … … 163 163 $_POST['_url'] = admin_url( 'edit-comments.php' ); 164 164 165 165 // Make the request 166 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );166 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 167 167 $this->_handleAjax( 'delete-comment' ); 168 168 } 169 169 -
tests/phpunit/tests/ajax/DimComment.php
127 127 $_POST['_url'] = admin_url( 'edit-comments.php' ); 128 128 129 129 // Make the request 130 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );130 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 131 131 $this->_handleAjax( 'dim-comment' ); 132 132 } 133 133 … … 154 154 $_POST['_url'] = admin_url( 'edit-comments.php' ); 155 155 156 156 // Make the request 157 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );157 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 158 158 $this->_handleAjax( 'dim-comment' ); 159 159 } 160 160 -
tests/phpunit/tests/ajax/EditComment.php
142 142 $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; 143 143 144 144 // Make the request 145 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );145 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 146 146 $this->_handleAjax( 'edit-comment' ); 147 147 } 148 148 … … 168 168 $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; 169 169 170 170 // Make the request 171 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );171 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 172 172 $this->_handleAjax( 'get-comments' ); 173 173 } 174 174 … … 188 188 $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; 189 189 190 190 // Make the request 191 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );191 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 192 192 $this->_handleAjax( 'edit-comment' ); 193 193 } 194 194 } -
tests/phpunit/tests/ajax/GetComments.php
88 88 $_POST['p'] = self::$comment_post->ID; 89 89 90 90 // Make the request 91 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );91 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 92 92 $this->_handleAjax( 'get-comments' ); 93 93 } 94 94 … … 108 108 $_POST['p'] = self::$comment_post->ID; 109 109 110 110 // Make the request 111 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );111 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 112 112 $this->_handleAjax( 'get-comments' ); 113 113 } 114 114 … … 128 128 $_POST['p'] = 'b0rk'; 129 129 130 130 // Make the request 131 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );131 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 132 132 $this->_handleAjax( 'get-comments' ); 133 133 } 134 134 … … 148 148 $_POST['p'] = self::$no_comment_post->ID; 149 149 150 150 // Make the request 151 $this-> setExpectedException( 'WPAjaxDieStopException', '1' );151 $this->_setExpectedException( 'WPAjaxDieStopException', '1' ); 152 152 $this->_handleAjax( 'get-comments' ); 153 153 } 154 154 } -
tests/phpunit/tests/ajax/ReplytoComment.php
107 107 $_POST['comment_post_ID'] = self::$comment_post->ID; 108 108 109 109 // Make the request 110 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );110 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 111 111 $this->_handleAjax( 'replyto-comment' ); 112 112 } 113 113 … … 134 134 $_POST['comment_post_ID'] = self::$comment_post->ID; 135 135 136 136 // Make the request 137 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );137 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 138 138 $this->_handleAjax( 'replyto-comment' ); 139 139 } 140 140 … … 154 154 $_POST['comment_post_ID'] = 123456789; 155 155 156 156 // Make the request 157 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );157 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 158 158 $this->_handleAjax( 'replyto-comment' ); 159 159 } 160 160 … … 174 174 $_POST['comment_post_ID'] = self::$draft_post->ID; 175 175 176 176 // Make the request 177 $this-> setExpectedException( 'WPAjaxDieStopException', 'ERROR: you are replying to a comment on a draft post.' );177 $this->_setExpectedException( 'WPAjaxDieStopException', 'ERROR: you are replying to a comment on a draft post.' ); 178 178 $this->_handleAjax( 'replyto-comment' ); 179 179 } 180 180 -
tests/phpunit/tests/ajax/TagSearch.php
68 68 69 69 // Make the request 70 70 // No output, so we get a stop exception 71 $this-> setExpectedException( 'WPAjaxDieStopException', '0' );71 $this->_setExpectedException( 'WPAjaxDieStopException', '0' ); 72 72 $this->_handleAjax( 'ajax-tag-search' ); 73 73 } 74 74 … … 108 108 $_GET['q'] = 'chat'; 109 109 110 110 // Make the request 111 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );111 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 112 112 $this->_handleAjax( 'ajax-tag-search' ); 113 113 } 114 114 … … 125 125 $_GET['q'] = 'chat'; 126 126 127 127 // Make the request 128 $this-> setExpectedException( 'WPAjaxDieStopException', '0' );128 $this->_setExpectedException( 'WPAjaxDieStopException', '0' ); 129 129 $this->_handleAjax( 'ajax-tag-search' ); 130 130 } 131 131 … … 142 142 $_GET['q'] = 'chat'; 143 143 144 144 // Make the request 145 $this-> setExpectedException( 'WPAjaxDieStopException', '-1' );145 $this->_setExpectedException( 'WPAjaxDieStopException', '-1' ); 146 146 $this->_handleAjax( 'ajax-tag-search' ); 147 147 } 148 148