From 9f899745ca25e95e8be3ce1dcacc1d841b1a4780 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Fri, 12 Jul 2019 06:12:02 +0200
Subject: [PATCH] Simplify & modernize some unit test functions

---
 tests/phpunit/includes/abstract-testcase.php | 7 +++----
 tests/phpunit/includes/utils.php             | 9 +++------
 tests/phpunit/tests/customize/manager.php    | 5 +++--
 tests/phpunit/tests/hooks/doAction.php       | 5 +++--
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
index 0dbcc7f45a..f1e2fdd88f 100644
--- a/tests/phpunit/includes/abstract-testcase.php
+++ b/tests/phpunit/includes/abstract-testcase.php
@@ -909,11 +909,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
 	 * @since 2.5.0
 	 * @since 3.8.0 Moved from `Tests_Query_Conditionals` to `WP_UnitTestCase`.
 	 *
-	 * @param string ...$prop Any number of WP_Query properties that are expected to be true for the current request.
+	 * @param string ...$true Any number of WP_Query properties that are expected to be true for the current request.
 	 */
-	public function assertQueryTrue() {
+	public function assertQueryTrue( ...$true ) {
 		global $wp_query;
-		$all  = array(
+		$all = array(
 			'is_404',
 			'is_admin',
 			'is_archive',
@@ -944,7 +944,6 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
 			'is_trackback',
 			'is_year',
 		);
-		$true = func_get_args();
 
 		foreach ( $true as $true_thing ) {
 			$this->assertContains( $true_thing, $all, "Unknown conditional: {$true_thing}." );
diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php
index f2131ac23f..a6c963806c 100644
--- a/tests/phpunit/includes/utils.php
+++ b/tests/phpunit/includes/utils.php
@@ -128,17 +128,16 @@ class MockAction {
 		return $arg . '_append';
 	}
 
-	function filterall( $tag, $arg = null ) {
+	function filterall( $tag, ...$args ) {
 		// this one doesn't return the result, so it's safe to use with the new 'all' filter
 		if ( $this->debug ) {
 			dmp( __FUNCTION__, $this->current_filter() );
 		}
 
-		$args           = func_get_args();
 		$this->events[] = array(
 			'filter' => __FUNCTION__,
 			'tag'    => $tag,
-			'args'   => array_slice( $args, 1 ),
+			'args'   => $args,
 		);
 	}
 
@@ -300,9 +299,7 @@ function xml_array_dumbdown( &$data ) {
 	return $out;
 }
 
-function dmp() {
-	$args = func_get_args();
-
+function dmp( ...$args ) {
 	foreach ( $args as $thing ) {
 		echo ( is_scalar( $thing ) ? strval( $thing ) : var_export( $thing, true ) ), "\n";
 	}
diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php
index f081245c6b..1cd3fddf6f 100644
--- a/tests/phpunit/tests/customize/manager.php
+++ b/tests/phpunit/tests/customize/manager.php
@@ -2541,10 +2541,11 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
 	 * Capture the actions fired when calling WP_Customize_Manager::set_post_value().
 	 *
 	 * @see Tests_WP_Customize_Manager::test_set_post_value()
+	 *
+	 * @param mixed ...$args Optional arguments passed to the action.
 	 */
-	function capture_customize_post_value_set_actions() {
+	function capture_customize_post_value_set_actions( ...$args ) {
 		$action = current_action();
-		$args   = func_get_args();
 		$this->captured_customize_post_value_set_actions[] = compact( 'action', 'args' );
 	}
 
diff --git a/tests/phpunit/tests/hooks/doAction.php b/tests/phpunit/tests/hooks/doAction.php
index 48ced32e1d..34f90eae3a 100644
--- a/tests/phpunit/tests/hooks/doAction.php
+++ b/tests/phpunit/tests/hooks/doAction.php
@@ -164,9 +164,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
 
 	/**
 	 * Use this rather than MockAction so we can test callbacks with no args
+	 *
+	 * @param mixed ...$args Optional arguments passed to the action.
 	 */
-	public function _action_callback() {
-		$args           = func_get_args();
+	public function _action_callback( ...$args ) {
 		$this->events[] = array(
 			'action' => __FUNCTION__,
 			'args'   => $args,
-- 
2.21.0.windows.1

