paged.php 746 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * @group canonical
  4. * @group rewrite
  5. * @group query
  6. */
  7. class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase {
  8. function test_redirect_canonical_with_nextpage_pagination() {
  9. $para = 'This is a paragraph.
  10. This is a paragraph.
  11. This is a paragraph.';
  12. $next = '<!--nextpage-->';
  13. $post_id = self::factory()->post->create(
  14. array(
  15. 'post_status' => 'publish',
  16. 'post_content' => "{$para}{$next}{$para}{$next}{$para}",
  17. )
  18. );
  19. $link = parse_url( get_permalink( $post_id ), PHP_URL_PATH );
  20. // Existing page should be displayed as is.
  21. $this->assertCanonical( $link . '3/', $link . '3/' );
  22. // Non-existing page should redirect to the permalink.
  23. $this->assertCanonical( $link . '4/', $link );
  24. }
  25. }