mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Add unit tests for get_next_posts_link() and get_previous_posts_link().
The tests ensure that the `next_posts_link_attributes` and `previous_posts_link_attributes` filters are applied correctly. Follow-up to [1383], [5045], [8502], [9632], [55429]. Props geisthanen, mukesh27, costdev, audrasjb, SergeyBiryukov. Fixes #55751. git-svn-id: https://develop.svn.wordpress.org/trunk@55442 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8ec9e42cc9
commit
b12e340f11
46
tests/phpunit/tests/link/getNextPostsLink.php
Normal file
46
tests/phpunit/tests/link/getNextPostsLink.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests the `get_next_posts_link()` function.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @group link
|
||||
*
|
||||
* @covers ::get_next_posts_link
|
||||
*/
|
||||
class Tests_Link_GetNextPostsLink extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Creates posts before any tests run.
|
||||
*
|
||||
* @param WP_UnitTest_Factory $factory
|
||||
*/
|
||||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||
global $wp_query, $paged;
|
||||
|
||||
$factory->post->create_many( 3 );
|
||||
$paged = 2;
|
||||
$wp_query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 1,
|
||||
'paged' => $paged,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the 'next_posts_link_attributes' filter is applied correctly.
|
||||
*
|
||||
* @ticket 55751
|
||||
*/
|
||||
public function test_get_next_posts_link_should_apply_next_posts_link_attributes_filter() {
|
||||
$filter = new MockAction();
|
||||
add_filter( 'next_posts_link_attributes', array( &$filter, 'filter' ) );
|
||||
|
||||
get_next_posts_link();
|
||||
|
||||
$this->assertSame( 1, $filter->get_call_count() );
|
||||
}
|
||||
}
|
||||
46
tests/phpunit/tests/link/getPreviousPostsLink.php
Normal file
46
tests/phpunit/tests/link/getPreviousPostsLink.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests the `get_previous_posts_link()` function.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @group link
|
||||
*
|
||||
* @covers ::get_previous_posts_link
|
||||
*/
|
||||
class Tests_Link_GetPreviousPostsLink extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Creates posts before any tests run.
|
||||
*
|
||||
* @param WP_UnitTest_Factory $factory
|
||||
*/
|
||||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||
global $wp_query, $paged;
|
||||
|
||||
$factory->post->create_many( 3 );
|
||||
$paged = 2;
|
||||
$wp_query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 1,
|
||||
'paged' => $paged,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the 'previous_posts_link_attributes' filter is applied correctly.
|
||||
*
|
||||
* @ticket 55751
|
||||
*/
|
||||
public function test_get_previous_posts_link_should_apply_previous_posts_link_attributes_filter() {
|
||||
$filter = new MockAction();
|
||||
add_filter( 'previous_posts_link_attributes', array( &$filter, 'filter' ) );
|
||||
|
||||
get_previous_posts_link();
|
||||
|
||||
$this->assertSame( 1, $filter->get_call_count() );
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests get_the_posts_navigation function.
|
||||
* Tests the `get_the_posts_navigation()` function.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user