- Timestamp:
- 09/24/2015 04:31:58 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/link/getPostCommentsFeedLink.php
r34477 r34479 4 4 */ 5 5 class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 6 private static $rewrite; 7 private static $permalink_structure; 8 9 static function setUpBeforeClass() { 10 global $wp_rewrite; 11 12 parent::setUpBeforeClass(); 13 14 self::$rewrite = $wp_rewrite; 15 self::$permalink_structure = get_option( 'permalink_structure' ); 16 } 17 18 public static function tearDownAfterClass() { 19 parent::tearDownAfterClass(); 20 21 self::$rewrite->init(); 22 self::$rewrite->set_permalink_structure( self::$permalink_structure ); 23 self::$rewrite->flush_rules(); 24 } 25 26 public function setUp() { 27 parent::setUp(); 28 self::$rewrite->init(); 29 } 30 31 private function set_permalink_structure( $structure ) { 32 self::$rewrite->set_permalink_structure( $structure ); 33 self::$rewrite->flush_rules(); 34 } 35 6 36 public function test_post_link() { 7 global $wp_rewrite; 8 $permalink_structure = get_option( 'permalink_structure' ); 9 $wp_rewrite->init(); 10 $wp_rewrite->set_permalink_structure( '' ); 11 $wp_rewrite->flush_rules(); 37 $this->set_permalink_structure( '' ); 12 38 13 39 $post_id = $this->factory->post->create(); … … 23 49 24 50 public function test_post_pretty_link() { 25 global $wp_rewrite; 26 $permalink_structure = get_option( 'permalink_structure' ); 27 $wp_rewrite->init(); 28 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 29 $wp_rewrite->flush_rules(); 51 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 30 52 31 53 $post_id = $this->factory->post->create(); … … 38 60 39 61 public function test_attachment_link() { 40 global $wp_rewrite; 41 $wp_rewrite->init(); 42 $wp_rewrite->set_permalink_structure( '' ); 43 $wp_rewrite->flush_rules(); 62 $this->set_permalink_structure( '' ); 44 63 45 64 $post_id = $this->factory->post->create(); … … 59 78 60 79 public function test_attachment_pretty_link() { 61 global $wp_rewrite; 62 $wp_rewrite->init(); 63 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 64 $wp_rewrite->flush_rules(); 80 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 65 81 66 82 $post_id = $this->factory->post->create( array( … … 82 98 83 99 public function test_attachment_no_name_pretty_link() { 84 global $wp_rewrite; 85 $wp_rewrite->init(); 86 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 87 $wp_rewrite->flush_rules(); 100 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 88 101 89 102 $post_id = $this->factory->post->create(); … … 95 108 $link = get_post_comments_feed_link( $attachment_id ); 96 109 $expected = get_permalink( $post_id ) . 'attachment/' . $attachment_id . '/feed/'; 97 110 98 111 $this->assertEquals( $expected, $link ); 99 112 } 100 113 101 114 public function test_unattached_link() { 102 global $wp_rewrite; 103 $wp_rewrite->init(); 104 $wp_rewrite->set_permalink_structure( '' ); 105 $wp_rewrite->flush_rules(); 115 $this->set_permalink_structure( '' ); 106 116 107 117 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( … … 120 130 121 131 public function test_unattached_pretty_link() { 122 global $wp_rewrite; 123 $wp_rewrite->init(); 124 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 125 $wp_rewrite->flush_rules(); 132 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 126 133 127 134 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
Note: See TracChangeset
for help on using the changeset viewer.