Changeset 44701 for trunk/tests/phpunit/includes/bootstrap.php
- Timestamp:
- 01/28/2019 02:10:24 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/bootstrap.php
r44536 r44701 8 8 */ 9 9 if ( class_exists( 'PHPUnit\Runner\Version' ) ) { 10 require_once dirname( __FILE__ ) . '/phpunit6 -compat.php';10 require_once dirname( __FILE__ ) . '/phpunit6/compat.php'; 11 11 } 12 12 … … 119 119 _delete_all_posts(); 120 120 121 require dirname( __FILE__ ) . '/testcase.php'; 121 if ( version_compare( tests_get_phpunit_version(), '7.0', '>=' ) ) { 122 require dirname( __FILE__ ) . '/phpunit7/testcase.php'; 123 } else { 124 require dirname( __FILE__ ) . '/testcase.php'; 125 } 126 122 127 require dirname( __FILE__ ) . '/testcase-rest-api.php'; 123 128 require dirname( __FILE__ ) . '/testcase-rest-controller.php'; … … 145 150 * how you call phpunit has no effect. 146 151 */ 147 class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt{152 class WP_PHPUnit_Util_Getopt { 148 153 protected $longOptions = array( 149 154 'exclude-group=', 150 155 'group=', 156 'verbose=', 151 157 ); 152 158 function __construct( $argv ) { … … 158 164 try { 159 165 if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { 160 PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );166 self::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); 161 167 } 162 168 } catch ( PHPUnit_Framework_Exception $e ) { … … 209 215 } 210 216 } 217 218 /** 219 * Copied from https://raw.githubusercontent.com/sebastianbergmann/phpunit/6.5.7/src/Util/Getopt.php 220 * 221 * @param $arg 222 * @param $long_options 223 * @param $opts 224 * @param $args 225 */ 226 protected static function parseLongOption( $arg, $long_options, &$opts, &$args ) { 227 $count = count( $long_options ); 228 $list = explode( '=', $arg ); 229 $opt = $list[0]; 230 $opt_arg = null; 231 232 if ( count( $list ) > 1 ) { 233 $opt_arg = $list[1]; 234 } 235 236 $opt_len = strlen( $opt ); 237 238 for ( $i = 0; $i < $count; $i++ ) { 239 $long_opt = $long_options[ $i ]; 240 $opt_start = substr( $long_opt, 0, $opt_len ); 241 242 if ( $opt_start != $opt ) { 243 continue; 244 } 245 246 $opt_rest = substr( $long_opt, $opt_len ); 247 248 if ( $opt_rest != '' && $opt[0] != '=' && $i + 1 < $count && 249 $opt == substr( $long_options[ $i + 1 ], 0, $opt_len ) ) { 250 throw new Exception( 251 "option --$opt is ambiguous" 252 ); 253 } 254 255 if ( substr( $long_opt, -1 ) == '=' ) { 256 if ( substr( $long_opt, -2 ) != '==' ) { 257 if ( ! strlen( $opt_arg ) ) { 258 if ( false === $opt_arg = current( $args ) ) { 259 throw new Exception( 260 "option --$opt requires an argument" 261 ); 262 } 263 next( $args ); 264 } 265 } 266 } elseif ( $opt_arg ) { 267 throw new Exception( 268 "option --$opt doesn't allow an argument" 269 ); 270 } 271 272 $full_option = '--' . preg_replace( '/={1,2}$/', '', $long_opt ); 273 $opts[] = array( $full_option, $opt_arg ); 274 275 return; 276 } 277 278 throw new Exception( "unrecognized option --$opt" ); 279 } 211 280 } 212 281 new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] );
Note: See TracChangeset
for help on using the changeset viewer.