Changeset 1526 for branches/3.0

Show
Ignore:
Timestamp:
11/28/2006 05:34:00 PM (2 years ago)
Author:
wei
Message:

Make simpletest E_STRICT compatible

Location:
branches/3.0/tests
Files:
2 added
14 modified

Legend:

Unmodified
Added
Removed
  • branches/3.0/tests/test_tools/simpletest/authentication.php

    r1397 r1526  
    1010     */ 
    1111    require_once(dirname(__FILE__) . '/http.php'); 
    12      
     12 
    1313    /** 
    1414     *    Represents a single security realm's identity. 
     
    2121        protected $_username; 
    2222        protected $_password; 
    23          
     23 
    2424        /** 
    2525         *    Starts with the initial entry directory. 
     
    3636            $this->_password = false; 
    3737        } 
    38          
     38 
    3939        /** 
    4040         *    Adds another location to the realm. 
     
    4545            $this->_root = $this->_getCommonPath($this->_root, $url->getPath()); 
    4646        } 
    47          
     47 
    4848        /** 
    4949         *    Finds the common starting path. 
     
    6363            return implode('/', $first) . '/'; 
    6464        } 
    65          
     65 
    6666        /** 
    6767         *    Sets the identity to try within this realm. 
     
    7474            $this->_password = $password; 
    7575        } 
    76          
     76 
    7777        /** 
    7878         *    Accessor for current identity. 
     
    8383            return $this->_username; 
    8484        } 
    85          
     85 
    8686        /** 
    8787         *    Accessor for current identity. 
     
    9292            return $this->_password; 
    9393        } 
    94          
     94 
    9595        /** 
    9696         *    Test to see if the URL is within the directory 
     
    109109            return false; 
    110110        } 
    111          
     111 
    112112        /** 
    113113         *    Tests to see if one string is a substring of 
     
    123123        } 
    124124    } 
    125      
     125 
    126126    /** 
    127127     *    Manages security realms. 
     
    131131    class SimpleAuthenticator { 
    132132        protected $_realms; 
    133          
     133 
    134134        /** 
    135135         *    Clears the realms. 
     
    139139            $this->restartSession(); 
    140140        } 
    141          
     141 
    142142        /** 
    143143         *    Starts with no realms set up. 
     
    147147            $this->_realms = array(); 
    148148        } 
    149          
     149 
    150150        /** 
    151151         *    Adds a new realm centered the current URL. 
     
    167167            $this->_realms[$url->getHost()][$realm] = new SimpleRealm($type, $url); 
    168168        } 
    169          
     169 
    170170        /** 
    171171         *    Sets the current identity to be presented 
     
    182182            } 
    183183        } 
    184          
     184 
    185185        /** 
    186186         *    Finds the name of the realm by comparing URLs. 
     
    200200            return false; 
    201201        } 
    202          
     202 
    203203        /** 
    204204         *    Presents the appropriate headers for this location. 
     
    219219            $this->addBasicHeaders($request, $username, $password); 
    220220        } 
    221          
     221 
    222222        /** 
    223223         *    Presents the appropriate headers for this 
     
    229229         *    @static 
    230230         */ 
    231         function addBasicHeaders($request, $username, $password) { 
     231        static function addBasicHeaders($request, $username, $password) { 
    232232            if ($username && $password) { 
    233233                $request->addHeaderLine( 
  • branches/3.0/tests/test_tools/simpletest/compatibility.php

    r1397 r1526  
    55     *  @version        $Id$ 
    66     */ 
    7      
     7 
    88    /** 
    99     *  Static methods for compatibility between different 
     
    1212     */ 
    1313    class SimpleTestCompatibility { 
    14          
     14 
    1515        /** 
    1616         *        Creates a copy whether in PHP5 or PHP4. 
     
    2020         *        @static 
    2121         */ 
    22         function copy($object) { 
     22        static function copy($object) { 
    2323            if (version_compare(phpversion(), '5') >= 0) { 
    2424                eval('$copy = clone $object;'); 
     
    2727            return $object; 
    2828        } 
    29          
     29 
    3030        /** 
    3131         *    Identity test. Drops back to equality + types for PHP5 
     
    3838         *    @static 
    3939         */ 
    40         function isIdentical($first, $second) { 
     40        static function isIdentical($first, $second) { 
    4141            if ($first != $second) { 
    4242                return false; 
     
    4747            return ($first === $second); 
    4848        } 
    49          
     49 
    5050        /** 
    5151         *    Recursive type test. 
     
    5656         *    @static 
    5757         */ 
    58         function _isIdenticalType($first, $second) { 
     58        static function _isIdenticalType($first, $second) { 
    5959            if (gettype($first) != gettype($second)) { 
    6060                return false; 
     
    7373            return true; 
    7474        } 
    75          
     75 
    7676        /** 
    7777         *    Recursive type test for each element of an array. 
     
    8282         *    @static 
    8383         */ 
    84         function _isArrayOfIdenticalTypes($first, $second) { 
     84        static function _isArrayOfIdenticalTypes($first, $second) { 
    8585            if (array_keys($first) != array_keys($second)) { 
    8686                return false; 
     
    9696            return true; 
    9797        } 
    98          
     98 
    9999        /** 
    100100         *    Test for two variables being aliases. 
     
    105105         *    @static 
    106106         */ 
    107         function isReference($first, $second) { 
     107        static function isReference($first, $second) { 
    108108            if (version_compare(phpversion(), '5', '>=') 
    109109                    && is_object($first)) { 
     
    123123            return $is_ref; 
    124124        } 
    125          
     125 
    126126        /** 
    127127         *    Test to see if an object is a member of a 
     
    133133         *    @static 
    134134         */ 
    135         function isA($object, $class) { 
     135        static function isA($object, $class) { 
    136136            if (version_compare(phpversion(), '5') >= 0) { 
    137137                if (! class_exists($class, false)) { 
     
    151151                    or (is_subclass_of($object, $class))); 
    152152        } 
    153          
     153 
    154154        /** 
    155155         *    Sets a socket timeout for each chunk. 
     
    159159         *    @static 
    160160         */ 
    161         function setTimeout($handle, $timeout) { 
     161        static function setTimeout($handle, $timeout) { 
    162162            if (function_exists('stream_set_timeout')) { 
    163163                stream_set_timeout($handle, $timeout, 0); 
     
    168168            } 
    169169        } 
    170          
     170 
    171171        /** 
    172172         *    Gets the current stack trace topmost first. 
     
    175175         *    @static 
    176176         */ 
    177         function getStackTrace() { 
     177        static function getStackTrace() { 
    178178            if (function_exists('debug_backtrace')) { 
    179179                return array_reverse(debug_backtrace()); 
  • branches/3.0/tests/test_tools/simpletest/dumper.php

    r1397 r1526  
    1212        define('TYPE_MATTERS', true); 
    1313    } 
    14      
     14 
    1515    /** 
    1616     *    Displays variables as text and does diffs. 
     
    1919     */ 
    2020    class SimpleDumper { 
    21          
     21 
    2222        /** 
    2323         *    Renders a variable in a shorter form than print_r(). 
     
    4444            return "Unknown"; 
    4545        } 
    46          
     46 
    4747        /** 
    4848         *    Gets the string representation of a type. 
     
    9696            return $this->$method($first, $second, $identical); 
    9797        } 
    98          
     98 
    9999        /** 
    100100         *    Tests to see if types match. 
     
    129129            return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : ""); 
    130130        } 
    131          
     131 
    132132        /** 
    133133         *    Creates a human readable description of the 
     
    144144                    $this->describeValue($second) . "]"; 
    145145        } 
    146          
     146 
    147147        /** 
    148148         *    Creates a human readable description of the 
     
    157157            return $this->_describeGenericDifference($first, $second); 
    158158        } 
    159          
     159 
    160160        /** 
    161161         *    Creates a human readable description of the 
     
    170170            return $this->_describeGenericDifference($first, $second); 
    171171        } 
    172          
     172 
    173173        /** 
    174174         *    Creates a human readable description of the 
     
    191191            return $message; 
    192192        } 
    193          
     193 
    194194        /** 
    195195         *    Creates a human readable description of the 
     
    210210                    abs($first - $second); 
    211211        } 
    212          
     212 
    213213        /** 
    214214         *    Creates a human readable description of the 
     
    229229                    abs($first - $second); 
    230230        } 
    231          
     231 
    232232        /** 
    233233         *    Creates a human readable description of the 
     
    262262            return ""; 
    263263        } 
    264          
     264 
    265265        /** 
    266266         *    Compares two arrays to see if their key lists match. 
     
    283283            return ($first_keys == $second_keys); 
    284284        } 
    285          
     285 
    286286        /** 
    287287         *    Creates a human readable description of the 
     
    296296            return $this->_describeGenericDifference($first, $second); 
    297297        } 
    298          
     298 
    299299        /** 
    300300         *    Creates a human readable description of the 
     
    315315                    $identical); 
    316316        } 
    317          
     317 
    318318        /** 
    319319         *    Find the first character position that differs 
     
    342342            return $position; 
    343343        } 
    344          
     344 
    345345        /** 
    346346         *    Sends a formatted dump of a variable to a string. 
     
    350350         *    @static 
    351351         */ 
    352         function dump($variable) { 
     352        static function dump($variable) { 
    353353            ob_start(); 
    354354            print_r($variable); 
     
    365365         *    @static 
    366366         */ 
    367         function getFormattedAssertionLine($stack) { 
     367        static function getFormattedAssertionLine($stack) { 
    368368            foreach ($stack as $frame) { 
    369369                if (isset($frame['file'])) { 
     
    380380            return ''; 
    381381        } 
    382          
     382 
    383383        /** 
    384384         *    Tries to determine if the method call is an assertion. 
     
    387387         *    @static 
    388388         */ 
    389         function _stackFrameIsAnAssertion($frame) { 
     389        static function _stackFrameIsAnAssertion($frame) { 
    390390            if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) { 
    391391                return true; 
  • branches/3.0/tests/test_tools/simpletest/expectation.php

    r1397 r1526  
    66     *    @version    $Id$ 
    77     */ 
    8       
     8 
    99    /**#@+ 
    1010     *    include other SimpleTest class files 
     
    1313    require_once(dirname(__FILE__) . '/compatibility.php'); 
    1414    /**#@-*/ 
    15      
     15 
    1616    /** 
    1717     *    Assertion that can display failure information. 
     
    2424        protected $_dumper; 
    2525        protected $_message; 
    26          
     26 
    2727        /** 
    2828         *    Creates a dumper for displaying values and sets 
     
    3434            $this->_message = $message; 
    3535        } 
    36          
     36 
    3737        /** 
    3838         *    Tests the expectation. True if correct. 
     
    4444        function test($compare) { 
    4545        } 
    46          
     46 
    4747        /** 
    4848         *    Returns a human readable test message. 
     
    5555        function testMessage($compare) { 
    5656        } 
    57          
     57 
    5858        /** 
    5959         *    Overlays the generated message onto the stored user 
     
    6767            return sprintf($this->_message, $this->testMessage($compare)); 
    6868        } 
    69          
     69 
    7070        /** 
    7171         *    Accessor for the dumper. 
     
    7676            return $this->_dumper; 
    7777        } 
    78          
     78 
    7979        /** 
    8080         *    Test to see if a value is an expectation object. 
     
    8787         *    @static 
    8888         */ 
    89         function isExpectation($expectation) { 
     89        static function isExpectation($expectation) { 
    9090            return is_object($expectation) && 
    9191                    SimpleTestCompatibility::isA($expectation, 'SimpleExpectation'); 
    9292        } 
    9393    } 
    94      
     94 
    9595    /** 
    9696     *    Test for equality. 
     
    100100    class EqualExpectation extends SimpleExpectation { 
    101101        protected $_value; 
    102          
     102 
    103103        /** 
    104104         *    Sets the value to compare against. 
     
    111111            $this->_value = $value; 
    112112        } 
    113          
     113 
    114114        /** 
    115115         *    Tests the expectation. True if it matches the 
     
    122122            return (($this->_value == $compare) && ($compare == $this->_value)); 
    123123        } 
    124          
     124 
    125125        /** 
    126126         *    Returns a human readable test message. 
     
    148148        } 
    149149    } 
    150      
     150 
    151151    /** 
    152152     *    Test for inequality. 
     
    155155     */ 
    156156    class NotEqualExpectation extends EqualExpectation { 
    157          
     157 
    158158        /** 
    159159         *    Sets the value to compare against. 
     
    165165            $this->EqualExpectation($value, $message); 
    166166        } 
    167          
     167 
    168168        /** 
    169169         *    Tests the expectation. True if it differs from the 
     
    176176            return ! parent::test($compare); 
    177177        } 
    178          
     178 
    179179        /** 
    180180         *    Returns a human readable test message. 
     
    196196