From 5d75f577762b316c977d468451afb0e00e170a03 Mon Sep 17 00:00:00 2001 From: dyszczo <krzysztof.dyszczyk@gmail.com> Date: Sun, 24 May 2020 19:10:46 +0100 Subject: [PATCH] tests --- tests/unit/TestGetStrategy.php | 2 +- tests/unit/TestPostTypeStrategy.php | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/unit/TestGetStrategy.php b/tests/unit/TestGetStrategy.php index da61448..7da82b5 100644 --- a/tests/unit/TestGetStrategy.php +++ b/tests/unit/TestGetStrategy.php @@ -29,7 +29,7 @@ class TestGetStrategy extends TestCase { $this->prepare_get(); } - public function testAndClausesFailureTest() { + public function testAndClausesFailure() { $strategy = new GetStrategy( [ [ self::true_1, diff --git a/tests/unit/TestPostTypeStrategy.php b/tests/unit/TestPostTypeStrategy.php index 8b0790f..31eb4ca 100644 --- a/tests/unit/TestPostTypeStrategy.php +++ b/tests/unit/TestPostTypeStrategy.php @@ -21,31 +21,32 @@ class TestPostTypeStrategy extends TestCase { \WP_Mock::tearDown(); } - public function testInvalidPostTypeFailure() { + public function testFailureWhenTriesUseInvalidPostType() { $strategy = new PostTypeStrategy( self::invalid_post_type ); $this->assertFalse( $strategy->shouldDisplay() ); } - public function testPostTypeUsingGetSuccess() { + public function testValidPostTypeUsingGetSuccess() { $_GET = [ 'post_type' => self::valid_post_type ]; $strategy = new PostTypeStrategy( self::valid_post_type ); $this->assertTrue( $strategy->shouldDisplay() ); } - public function testPostTypeUsingPostSuccess() { + public function testValidPostTypeUsingPostIdSuccess() { $post_id = 123; - $_GET = [ + $_GET = [ 'post' => $post_id ]; - \WP_Mock::userFunction('get_post', [ - 'times' => 1, - 'return' => function() use ($post_id) { - $post = new \WP_Post(); - $post->ID = $post_id; + \WP_Mock::userFunction( 'get_post', [ + 'times' => 1, + 'return' => function () use ( $post_id ) { + $post = new \WP_Post(); + $post->ID = $post_id; $post->post_type = self::valid_post_type; + return $post; } - ]); + ] ); $strategy = new PostTypeStrategy( self::valid_post_type ); $this->assertTrue( $strategy->shouldDisplay() ); -- GitLab