diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 44f0fdb69cf286540e6bbbde564f4d9f095e50a5..2bff769f357d6564eed7ebf3b12b6cdff5647bc9 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 646d359baa6c7909a0870690bf294543fe9122ef..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..56749f65ae4ebd15148352b334b4371d846d9f4a --- /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' ) ); + } +}