Changeset 46127
- Timestamp:
- 09/15/2019 11:03:45 AM (5 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r45588 r46127 904 904 * 905 905 * Any properties that are listed by name as parameters will be expected to be true; all others are 906 * expected to be false. For example, assertQueryTrue( 'is_single', 'is_feed') means is_single()906 * expected to be false. For example, assertQueryTrue( 'is_single', 'is_feed' ) means is_single() 907 907 * and is_feed() must be true and everything else must be false to pass. 908 908 * … … 912 912 * @param string ...$prop Any number of WP_Query properties that are expected to be true for the current request. 913 913 */ 914 public function assertQueryTrue( ) {914 public function assertQueryTrue( ...$prop ) { 915 915 global $wp_query; 916 $all = array( 916 917 $all = array( 917 918 'is_404', 918 919 'is_admin', … … 945 946 'is_year', 946 947 ); 947 $true = func_get_args(); 948 949 foreach ( $true as $true_thing ) { 948 949 foreach ( $prop as $true_thing ) { 950 950 $this->assertContains( $true_thing, $all, "Unknown conditional: {$true_thing}." ); 951 951 } … … 957 957 $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing; 958 958 959 if ( in_array( $query_thing, $ true, true ) ) {959 if ( in_array( $query_thing, $prop, true ) ) { 960 960 if ( ! $result ) { 961 961 $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL; -
trunk/tests/phpunit/includes/utils.php
r45607 r46127 129 129 } 130 130 131 function filterall( $tag, $arg = null) {131 function filterall( $tag, ...$args ) { 132 132 // this one doesn't return the result, so it's safe to use with the new 'all' filter 133 133 if ( $this->debug ) { … … 135 135 } 136 136 137 $args = func_get_args();138 137 $this->events[] = array( 139 138 'filter' => __FUNCTION__, 140 139 'tag' => $tag, 141 'args' => array_slice( $args, 1 ),140 'args' => $args, 142 141 ); 143 142 } … … 245 244 } 246 245 247 function xml_find( $tree /*, $el1, $el2, $el3, .. */ ) { 248 $a = func_get_args(); 249 $a = array_slice( $a, 1 ); 250 $n = count( $a ); 246 function xml_find( $tree, ...$elements ) { 247 $n = count( $elements ); 251 248 $out = array(); 252 249 … … 256 253 257 254 for ( $i = 0; $i < count( $tree ); $i++ ) { 258 # echo "checking '{$tree[$i][name]}' == '{$ a[0]}'\n";259 # var_dump( $tree[$i]['name'], $a[0]);260 if ( $tree[ $i ]['name'] === $ a[0] ) {255 # echo "checking '{$tree[$i][name]}' == '{$elements[0]}'\n"; 256 # var_dump( $tree[$i]['name'], $elements[0] ); 257 if ( $tree[ $i ]['name'] === $elements[0] ) { 261 258 # echo "n == {$n}\n"; 262 259 if ( 1 === $n ) { 263 260 $out[] = $tree[ $i ]; 264 261 } else { 265 $subtree =& $tree[ $i ]['child']; 266 $call_args = array( $subtree ); 267 $call_args = array_merge( $call_args, array_slice( $a, 1 ) ); 268 $out = array_merge( $out, call_user_func_array( 'xml_find', $call_args ) ); 262 $subtree =& $tree[ $i ]['child']; 263 $out = array_merge( $out, xml_find( $subtree, ...array_slice( $elements, 1 ) ) ); 269 264 } 270 265 } … … 301 296 } 302 297 303 function dmp() { 304 $args = func_get_args(); 305 298 function dmp( ...$args ) { 306 299 foreach ( $args as $thing ) { 307 300 echo ( is_scalar( $thing ) ? strval( $thing ) : var_export( $thing, true ) ), "\n"; -
trunk/tests/phpunit/tests/customize/manager.php
r45607 r46127 2542 2542 * 2543 2543 * @see Tests_WP_Customize_Manager::test_set_post_value() 2544 */ 2545 function capture_customize_post_value_set_actions() { 2544 * 2545 * @param mixed ...$args Optional arguments passed to the action. 2546 */ 2547 function capture_customize_post_value_set_actions( ...$args ) { 2546 2548 $action = current_action(); 2547 $args = func_get_args();2548 2549 $this->captured_customize_post_value_set_actions[] = compact( 'action', 'args' ); 2549 2550 } -
trunk/tests/phpunit/tests/hooks/doAction.php
r42343 r46127 165 165 /** 166 166 * Use this rather than MockAction so we can test callbacks with no args 167 * 168 * @param mixed ...$args Optional arguments passed to the action. 167 169 */ 168 public function _action_callback() { 169 $args = func_get_args(); 170 public function _action_callback( ...$args ) { 170 171 $this->events[] = array( 171 172 'action' => __FUNCTION__,
Note: See TracChangeset
for help on using the changeset viewer.