Skip to content
Snippets Groups Projects
Commit 5d75f577 authored by dyszczo's avatar dyszczo
Browse files

tests

parent 3c368084
No related branches found
No related tags found
1 merge request!1Feature/init
Pipeline #1949 failed with stages
in 1 minute and 45 seconds
......@@ -29,7 +29,7 @@ class TestGetStrategy extends TestCase {
$this->prepare_get();
}
public function testAndClausesFailureTest() {
public function testAndClausesFailure() {
$strategy = new GetStrategy( [
[
self::true_1,
......
......@@ -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() );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment