From f16eee492ad2491038792ca85245d1dc7ebe91d8 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Mon, 11 Sep 2017 14:30:38 -0700
Subject: [PATCH] Fix *list tests to respect underlying functions

---
 tests/tests/class-plugin-functions.php | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/tests/tests/class-plugin-functions.php b/tests/tests/class-plugin-functions.php
index 56749f6..9d1b7b7 100644
--- a/tests/tests/class-plugin-functions.php
+++ b/tests/tests/class-plugin-functions.php
@@ -16,16 +16,30 @@ class SampleTest extends WP_UnitTestCase {
 	/**
 	 * Test whitelisted commands
 	 */
-	function test_whitelist() {
-		$this->assertTrue( WP_CLI_Cron_Control_Offload\is_command_allowed( 'wp post list' ) );
-		$this->assertTrue( WP_CLI_Cron_Control_Offload\is_command_allowed( 'post list' ) );
+	function test_whitelist_using_is_command_allowed() {
+		$this->assertTrue( WP_CLI_Cron_Control_Offload\is_command_allowed( 'post' ) );
 	}
 
 	/**
 	 * Test blacklisted commands
 	 */
-	function test_blacklist() {
-		$this->assertFalse( WP_CLI_Cron_Control_Offload\is_command_allowed( 'wp cli info' ) );
-		$this->assertFalse( WP_CLI_Cron_Control_Offload\is_command_allowed( 'cli info' ) );
+	function test_blacklist_using_is_command_allowed() {
+		$this->assertFalse( WP_CLI_Cron_Control_Offload\is_command_allowed( 'cli' ) );
+	}
+
+	/**
+	 * Test whitelisted command validation
+	 */
+	function test_whitelist_using_validate_command() {
+		$this->assertTrue( is_string( WP_CLI_Cron_Control_Offload\validate_command( 'wp post list' ) ) );
+		$this->assertTrue( is_string( WP_CLI_Cron_Control_Offload\validate_command( 'post list' ) ) );
+	}
+
+	/**
+	 * Test blacklisted command validation
+	 */
+	function test_blacklist_using_validate_command() {
+		$this->assertTrue( is_wp_error( WP_CLI_Cron_Control_Offload\validate_command( 'wp cli info' ) ) );
+		$this->assertTrue( is_wp_error( WP_CLI_Cron_Control_Offload\validate_command( 'cli info' ) ) );
 	}
 }
-- 
GitLab