Make WordPress Core

Ticket #26725: wordpress-test-boostrap-argument-exception-fix.patch

File wordpress-test-boostrap-argument-exception-fix.patch, 1.8 KB (added by wawco, 11 years ago)

Implementing changes to the boostrap.php to ingore PHPUnit framework exceptions

  • includes/bootstrap.php

     
    8787/**
    8888 * A child class of the PHP test runner.
    8989 *
    90  * Not actually used as a runner. Rather, used to access the protected
    91  * longOptions property, to parse the arguments passed to the script.
     90 * Used to access the protected longOptions property, to parse the arguments
     91 * passed to the script.
    9292 *
    9393 * If it is determined that phpunit was called with a --group that corresponds
    9494 * to an @ticket annotation (such as `phpunit --group 12345` for bugs marked
     
    9797 * If WP_TESTS_FORCE_KNOWN_BUGS is already set in wp-tests-config.php, then
    9898 * how you call phpunit has no effect.
    9999 */
    100 class WP_PHPUnit_TextUI_Command extends PHPUnit_TextUI_Command {
     100class WP_HPUnit_Util_Getopt extends PHPUnit_Util_Getopt {
     101        protected $longOptions = array(
     102          'exclude-group=',
     103          'group=',
     104        );
    101105        function __construct( $argv ) {
    102                 $options = PHPUnit_Util_Getopt::getopt(
    103                         $argv,
    104                         'd:c:hv',
    105                         array_keys( $this->longOptions )
    106                 );
     106                $options = array();
     107                while ( list( $i, $arg ) = each( $argv ) ) {
     108                        try {
     109                                if ( strlen( $arg ) > 1 && $arg[1] == '-') {
     110                                        PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );
     111                                }
     112                        }
     113                        catch ( PHPUnit_Framework_Exception $e ) {
     114                                // Enforcing recognized arguments or correctly formed arguments is
     115                                // not really the concern here.
     116                                continue;
     117                        }
     118                }
    107119                $ajax_message = true;
    108120                foreach ( $options[0] as $option ) {
    109121                        switch ( $option[0] ) {
     
    124136                        echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL;
    125137    }
    126138}
    127 new WP_PHPUnit_TextUI_Command( $_SERVER['argv'] );
     139new WP_HPUnit_Util_Getopt( $_SERVER['argv'] );