diff --git a/phpunit.xml b/phpunit.xml index 16a39027e72be2cf0a2656056074b6e6ed818be1..3dca2e048d5ebb1fe38812fb848327348d55bb0f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,9 +8,8 @@ convertWarningsToExceptions="true" > <testsuites> - <testsuite> + <testsuite name="Autopaging"> <directory prefix="test-" suffix=".php">./tests/</directory> - <exclude>./tests/test-sample.php</exclude> </testsuite> </testsuites> </phpunit> diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8ce78728ba2e00d945d51e592c83c28e6b6c9525..db83740c906065df16a5a1479fee548fea8dc99e 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,7 +5,7 @@ * @package Automatically_Paginate_Posts */ -$autopaging_tests_dir = getenv( 'WPautopaging_tests_dir' ); +$autopaging_tests_dir = getenv( 'WP_TESTS_DIR' ); if ( ! $autopaging_tests_dir ) { $autopaging_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; diff --git a/tests/test-automatically-paginate-posts.php b/tests/test-automatically-paginate-posts.php new file mode 100755 index 0000000000000000000000000000000000000000..31b1b28d4a503212a46e18b7f543a703c3e1fff7 --- /dev/null +++ b/tests/test-automatically-paginate-posts.php @@ -0,0 +1,59 @@ +<?php +/** + * Test main plugin class. + * + * @package Automatically_Paginate_Posts + */ + +/** + * @coversDefaultClass Automatically_Paginate_Posts + */ +class SampleTest extends WP_UnitTestCase { + protected $_instance; + + public function set_up() { + parent::set_up(); + + $this->_instance = new Automatically_Paginate_Posts(); + } + + /** + * @covers ::__get() + */ + public function test___get() { + $this->assertEquals( + '_disable_autopaging', + $this->_instance->meta_key, + 'Failed to assert meta key matched expected value.' + ); + + // TODO: consider testing `post_types` along with a filter. + + $this->assertNull( + $this->_instance->unit_test, + 'Failed to assert that unsupported key returns null.' + ); + } + + /** + * @covers ::filter_plugin_action_links() + */ + public function test_filter_plugin_action_links() { + $this->assertEmpty( + $this->_instance->filter_plugin_action_links( + array(), + 'unit-test.php' + ), + 'Failed to assert that no change is made for other plugins..' + ); + + $this->assertArrayHasKey( + 'settings', + $this->_instance->filter_plugin_action_links( + array(), + 'automatically-paginate-posts/automatically-paginate-posts.php' + ), + 'Failed to assert that settings link is added for this plugin.' + ); + } +} diff --git a/tests/test-sample.php b/tests/test-sample.php deleted file mode 100755 index 16942743beafad9447ece39c65eb6cb79bff90b2..0000000000000000000000000000000000000000 --- a/tests/test-sample.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - * Class SampleTest - * - * @package Automatically_Paginate_Posts - */ - -/** - * Sample test case. - */ -class SampleTest extends WP_UnitTestCase { - - /** - * A single example test. - */ - public function test_sample() { - // Replace this with some actual testing code. - $this->assertTrue( true ); - } -}