Unit Tests: after [34477], make Tests_Link_GetPostCommentsFeedLink
more respectable.
See #33693. git-svn-id: https://develop.svn.wordpress.org/trunk@34479 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e1fafc56d5
commit
e366584fae
@ -3,12 +3,38 @@
|
|||||||
* @group link
|
* @group link
|
||||||
*/
|
*/
|
||||||
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
||||||
public function test_post_link() {
|
private static $rewrite;
|
||||||
|
private static $permalink_structure;
|
||||||
|
|
||||||
|
static function setUpBeforeClass() {
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$permalink_structure = get_option( 'permalink_structure' );
|
|
||||||
$wp_rewrite->init();
|
parent::setUpBeforeClass();
|
||||||
$wp_rewrite->set_permalink_structure( '' );
|
|
||||||
$wp_rewrite->flush_rules();
|
self::$rewrite = $wp_rewrite;
|
||||||
|
self::$permalink_structure = get_option( 'permalink_structure' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tearDownAfterClass() {
|
||||||
|
parent::tearDownAfterClass();
|
||||||
|
|
||||||
|
self::$rewrite->init();
|
||||||
|
self::$rewrite->set_permalink_structure( self::$permalink_structure );
|
||||||
|
self::$rewrite->flush_rules();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
self::$rewrite->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_permalink_structure( $structure ) {
|
||||||
|
self::$rewrite->set_permalink_structure( $structure );
|
||||||
|
self::$rewrite->flush_rules();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_post_link() {
|
||||||
|
$this->set_permalink_structure( '' );
|
||||||
|
|
||||||
$post_id = $this->factory->post->create();
|
$post_id = $this->factory->post->create();
|
||||||
|
|
||||||
@ -22,11 +48,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_post_pretty_link() {
|
public function test_post_pretty_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||||
$permalink_structure = get_option( 'permalink_structure' );
|
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$post_id = $this->factory->post->create();
|
$post_id = $this->factory->post->create();
|
||||||
|
|
||||||
@ -37,10 +59,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_attachment_link() {
|
public function test_attachment_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '' );
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$post_id = $this->factory->post->create();
|
$post_id = $this->factory->post->create();
|
||||||
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
|
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
|
||||||
@ -58,10 +77,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_attachment_pretty_link() {
|
public function test_attachment_pretty_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$post_id = $this->factory->post->create( array(
|
$post_id = $this->factory->post->create( array(
|
||||||
'post_status' => 'publish'
|
'post_status' => 'publish'
|
||||||
@ -81,10 +97,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_attachment_no_name_pretty_link() {
|
public function test_attachment_no_name_pretty_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$post_id = $this->factory->post->create();
|
$post_id = $this->factory->post->create();
|
||||||
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
|
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
|
||||||
@ -99,10 +112,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_unattached_link() {
|
public function test_unattached_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '' );
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
|
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
|
||||||
'post_mime_type' => 'image/jpeg',
|
'post_mime_type' => 'image/jpeg',
|
||||||
@ -119,10 +129,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test_unattached_pretty_link() {
|
public function test_unattached_pretty_link() {
|
||||||
global $wp_rewrite;
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||||
$wp_rewrite->init();
|
|
||||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
||||||
$wp_rewrite->flush_rules();
|
|
||||||
|
|
||||||
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
|
$attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
|
||||||
'post_mime_type' => 'image/jpeg',
|
'post_mime_type' => 'image/jpeg',
|
||||||
|
Loading…
Reference in New Issue
Block a user