From 5c3a87aaa9bbebdca090c4270c21049d63eefb98 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Tue, 28 Jun 2022 19:32:39 -0700 Subject: [PATCH] Test coverage --- tests/test-automatically-paginate-posts.php | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/test-automatically-paginate-posts.php b/tests/test-automatically-paginate-posts.php index c3fad45..cc87646 100755 --- a/tests/test-automatically-paginate-posts.php +++ b/tests/test-automatically-paginate-posts.php @@ -112,8 +112,18 @@ class Test_Automatically_Paginate_Posts extends WP_UnitTestCase { $post = $this->factory->post->create_and_get( $input['post_args'] ); update_option( 'autopaging_paging_type', $input['type'] ); - update_option( 'autopaging_num_pages', $input['num_pages'] ); - update_option( 'autopaging_num_words', $input['num_words'] ); + add_filter( + 'autopaging_num_pages', + static function() use( $input ) { + return $input['num_pages']; + } + ); + add_filter( + 'autopaging_num_words', + static function() use( $input ) { + return $input['num_words']; + } + ); $this->assertEquals( $expected, @@ -164,6 +174,18 @@ class Test_Automatically_Paginate_Posts extends WP_UnitTestCase { 'num_words' => 2, ), ), + 'Classic post, three pages' => array( + "1<!--nextpage-->\r\n\r\n2<!--nextpage-->\r\n\r\n3", + array( + 'post_args' => array( + 'post_type' => 'post', + 'post_content' => "1\r\n\r\n2\r\n\r\n3", + ), + 'type' => 'pages', + 'num_pages' => 3, + 'num_words' => 2, + ), + ), ); } } -- GitLab