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
|
b
|
class Tests_DB extends WP_UnitTestCase { |
| 422 | 422 | public function test_prepare_incorrect_arg_count( $query, $args, $expected ) { |
| 423 | 423 | global $wpdb; |
| 424 | 424 | |
| 425 | | // $query is the first argument to be passed to wpdb::prepare() |
| 426 | | array_unshift( $args, $query ); |
| 427 | | |
| 428 | | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
| 429 | | $prepared = @call_user_func_array( array( $wpdb, 'prepare' ), $args ); |
| | 425 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.DB.PreparedSQL |
| | 426 | $prepared = @$wpdb->prepare( $query, ...$args ); |
| 430 | 427 | $this->assertEquals( $expected, $prepared ); |
| 431 | 428 | } |
| 432 | 429 | |
| … |
… |
class Tests_DB extends WP_UnitTestCase { |
| 1366 | 1363 | $values = array( $values ); |
| 1367 | 1364 | } |
| 1368 | 1365 | |
| 1369 | | array_unshift( $values, $sql ); |
| 1370 | | |
| 1371 | | $sql = call_user_func_array( array( $wpdb, 'prepare' ), $values ); |
| | 1366 | // phpcs:ignore WordPress.DB.PreparedSQL |
| | 1367 | $sql = $wpdb->prepare( $sql, ...$values ); |
| 1372 | 1368 | $this->assertEquals( $expected, $sql ); |
| 1373 | 1369 | } |
| 1374 | 1370 | |
| … |
… |
class Tests_DB extends WP_UnitTestCase { |
| 1386 | 1382 | $values = array( $values ); |
| 1387 | 1383 | } |
| 1388 | 1384 | |
| 1389 | | $sql = call_user_func_array( array( $wpdb, 'prepare' ), array( $sql, $values ) ); |
| | 1385 | // phpcs:ignore WordPress.DB.PreparedSQL |
| | 1386 | $sql = $wpdb->prepare( $sql, $values ); |
| 1390 | 1387 | $this->assertEquals( $expected, $sql ); |
| 1391 | 1388 | } |
| 1392 | 1389 | |