From 66da481c14f2cd94748fb6767376499ad4de1019 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 28 Oct 2022 14:08:20 +0000 Subject: [PATCH] Tests: Move the tests for `WP` class methods to the `wp` directory. This aims to bring some consistency to the location of the tests for this class. Includes adding the missing `@covers` tags. Follow-up to [36177], [51622], [54250]. Props pbearne, SergeyBiryukov. See #56793, #56782. git-svn-id: https://develop.svn.wordpress.org/trunk@54710 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/{wp.php => wp/addQueryVar.php} | 15 +++------- tests/phpunit/tests/wp/parseRequest.php | 2 ++ tests/phpunit/tests/wp/removeQueryVar.php | 29 +++++++++++++++++++ tests/phpunit/tests/wp/sendHeaders.php | 1 + 4 files changed, 36 insertions(+), 11 deletions(-) rename tests/phpunit/tests/{wp.php => wp/addQueryVar.php} (61%) create mode 100644 tests/phpunit/tests/wp/removeQueryVar.php diff --git a/tests/phpunit/tests/wp.php b/tests/phpunit/tests/wp/addQueryVar.php similarity index 61% rename from tests/phpunit/tests/wp.php rename to tests/phpunit/tests/wp/addQueryVar.php index 4fbb182a50..421c76a665 100644 --- a/tests/phpunit/tests/wp.php +++ b/tests/phpunit/tests/wp/addQueryVar.php @@ -2,8 +2,11 @@ /** * @group wp + * + * @covers WP::add_query_var */ -class Tests_WP extends WP_UnitTestCase { +class Tests_WP_AddQueryVar extends WP_UnitTestCase { + /** * @var WP */ @@ -25,14 +28,4 @@ class Tests_WP extends WP_UnitTestCase { $this->assertContains( 'test', $this->wp->public_query_vars ); $this->assertContains( 'test2', $this->wp->public_query_vars ); } - - public function test_remove_query_var() { - $public_qv_count = count( $this->wp->public_query_vars ); - - $this->wp->add_query_var( 'test' ); - $this->assertContains( 'test', $this->wp->public_query_vars ); - $this->wp->remove_query_var( 'test' ); - - $this->assertCount( $public_qv_count, $this->wp->public_query_vars ); - } } diff --git a/tests/phpunit/tests/wp/parseRequest.php b/tests/phpunit/tests/wp/parseRequest.php index edf65cb660..a34a873e89 100644 --- a/tests/phpunit/tests/wp/parseRequest.php +++ b/tests/phpunit/tests/wp/parseRequest.php @@ -2,9 +2,11 @@ /** * @group wp + * * @covers WP::parse_request */ class Tests_WP_ParseRequest extends WP_UnitTestCase { + /** * @var WP */ diff --git a/tests/phpunit/tests/wp/removeQueryVar.php b/tests/phpunit/tests/wp/removeQueryVar.php new file mode 100644 index 0000000000..56d82c1774 --- /dev/null +++ b/tests/phpunit/tests/wp/removeQueryVar.php @@ -0,0 +1,29 @@ +wp = new WP(); + } + + public function test_remove_query_var() { + $public_qv_count = count( $this->wp->public_query_vars ); + + $this->wp->add_query_var( 'test' ); + $this->assertContains( 'test', $this->wp->public_query_vars ); + $this->wp->remove_query_var( 'test' ); + + $this->assertCount( $public_qv_count, $this->wp->public_query_vars ); + } +} diff --git a/tests/phpunit/tests/wp/sendHeaders.php b/tests/phpunit/tests/wp/sendHeaders.php index 84feb74d1d..b5fc56bf20 100644 --- a/tests/phpunit/tests/wp/sendHeaders.php +++ b/tests/phpunit/tests/wp/sendHeaders.php @@ -2,6 +2,7 @@ /** * @group wp + * * @covers WP::send_headers */ class Tests_WP_SendHeaders extends WP_UnitTestCase {