From 46d8e235ddb6f3c96982e1235e7f68a867f62d33 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sat, 20 Jul 2019 20:27:23 +0200
Subject: [PATCH] Simplify & modernize select unit tests

---
 tests/phpunit/tests/db.php | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php
index 0583ae132a..842246528d 100644
--- a/tests/phpunit/tests/db.php
+++ b/tests/phpunit/tests/db.php
@@ -422,11 +422,8 @@ class Tests_DB extends WP_UnitTestCase {
 	public function test_prepare_incorrect_arg_count( $query, $args, $expected ) {
 		global $wpdb;
 
-		// $query is the first argument to be passed to wpdb::prepare()
-		array_unshift( $args, $query );
-
-		// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
-		$prepared = @call_user_func_array( array( $wpdb, 'prepare' ), $args );
+		// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.DB.PreparedSQL
+		$prepared = @$wpdb->prepare( $query, ...$args );
 		$this->assertEquals( $expected, $prepared );
 	}
 
@@ -1366,9 +1363,8 @@ class Tests_DB extends WP_UnitTestCase {
 			$values = array( $values );
 		}
 
-		array_unshift( $values, $sql );
-
-		$sql = call_user_func_array( array( $wpdb, 'prepare' ), $values );
+		// phpcs:ignore WordPress.DB.PreparedSQL
+		$sql = $wpdb->prepare( $sql, ...$values );
 		$this->assertEquals( $expected, $sql );
 	}
 
@@ -1386,7 +1382,8 @@ class Tests_DB extends WP_UnitTestCase {
 			$values = array( $values );
 		}
 
-		$sql = call_user_func_array( array( $wpdb, 'prepare' ), array( $sql, $values ) );
+		// phpcs:ignore WordPress.DB.PreparedSQL
+		$sql = $wpdb->prepare( $sql, $values );
 		$this->assertEquals( $expected, $sql );
 	}
 
-- 
2.21.0.windows.1

