From 3338de9b6470ea3be229eece6d52ae437a19c5f9 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Mon, 11 Sep 2017 14:18:57 -0700
Subject: [PATCH] Introduce first tests, and fix test structure to appease
 PHPCS

---
 phpunit.xml.dist                       |  2 +-
 tests/test-sample.php                  | 20 -----------------
 tests/tests/class-plugin-functions.php | 31 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 21 deletions(-)
 delete mode 100644 tests/test-sample.php
 create mode 100644 tests/tests/class-plugin-functions.php

diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 44f0fdb..2bff769 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -8,7 +8,7 @@
 	>
 	<testsuites>
 		<testsuite>
-			<directory prefix="test-" suffix=".php">./tests/</directory>
+			<directory suffix=".php">./tests/tests/</directory>
 		</testsuite>
 	</testsuites>
 </phpunit>
diff --git a/tests/test-sample.php b/tests/test-sample.php
deleted file mode 100644
index 646d359..0000000
--- a/tests/test-sample.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/**
- * Class SampleTest
- *
- * @package WP_CLI_Cron_Control_Offload
- */
-
-/**
- * Sample test case.
- */
-class SampleTest extends WP_UnitTestCase {
-
-	/**
-	 * A single example test.
-	 */
-	function test_sample() {
-		// Replace this with some actual testing code.
-		$this->assertTrue( true );
-	}
-}
diff --git a/tests/tests/class-plugin-functions.php b/tests/tests/class-plugin-functions.php
new file mode 100644
index 0000000..56749f6
--- /dev/null
+++ b/tests/tests/class-plugin-functions.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Test plugin's common functions
+ *
+ * @package WP_CLI_Cron_Control_Offload
+ */
+
+namespace Automattic\WP\WP_CLI_Cron_Control_Offload\Tests;
+use Automattic\WP\WP_CLI_Cron_Control_Offload;
+use WP_UnitTestCase;
+
+/**
+ * Sample test case.
+ */
+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' ) );
+	}
+
+	/**
+	 * 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' ) );
+	}
+}
-- 
GitLab