From 7a3c12d9851a40ddb1301245611e5dd3f175e644 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 28 Mar 2014 03:01:43 +0000 Subject: [PATCH] Add a unit test for shortlinks of a page on front. see #26871, see [27802]. git-svn-id: https://develop.svn.wordpress.org/trunk@27803 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/link.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/tests/link.php b/tests/phpunit/tests/link.php index dc1ee06051..557bed0ec6 100644 --- a/tests/phpunit/tests/link.php +++ b/tests/phpunit/tests/link.php @@ -96,6 +96,27 @@ class Tests_Link extends WP_UnitTestCase { $wp_rewrite->flush_rules(); } + /** + * @ticket 26871 + */ + function test_wp_get_shortlink_with_home_page() { + $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + update_option( 'show_on_front', 'page' ); + update_option( 'page_on_front', $post_id ); + + $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); + + global $wp_rewrite; + $wp_rewrite->permalink_structure = ''; + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + $wp_rewrite->flush_rules(); + + $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); + + $wp_rewrite->set_permalink_structure( '' ); + $wp_rewrite->flush_rules(); + } + /** * @ticket 17807 */