Changeset 34687 for trunk/tests/phpunit/tests/user/author.php
- Timestamp:
- 09/29/2015 05:37:00 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/author.php
r31098 r34687 2 2 3 3 /** 4 * Test functions in wp-includes/author .php, author-template.php4 * Test functions in wp-includes/author-template.php 5 5 * 6 6 * @group author 7 7 * @group user 8 8 */ 9 class Tests_User_Author extends WP_UnitTestCase { 10 protected $old_post_id = 0; 9 class Tests_User_Author_Template extends WP_UnitTestCase { 11 10 protected $author_id = 0; 12 11 protected $post_id = 0; 13 12 13 private $permalink_structure; 14 14 15 function setUp() { 15 16 parent::setUp(); 17 18 global $wp_rewrite; 19 $this->permalink_structure = get_option( 'permalink_structure' ); 20 $wp_rewrite->set_permalink_structure( '' ); 21 $wp_rewrite->flush_rules(); 16 22 17 23 $this->author_id = $this->factory->user->create( array( … … 37 43 38 44 function tearDown() { 45 global $wp_rewrite; 46 $wp_rewrite->set_permalink_structure( $this->permalink_structure ); 47 $wp_rewrite->flush_rules(); 48 39 49 wp_reset_postdata(); 40 50 parent::tearDown(); … … 100 110 _unregister_post_type( 'wptests_pt' ); 101 111 } 112 113 /** 114 * @ticket 30355 115 */ 116 public function test_get_the_author_posts_link_no_permalinks() { 117 $author = $this->factory->user->create_and_get( array( 118 'display_name' => 'Foo', 119 'user_nicename' => 'bar' 120 ) ); 121 122 $GLOBALS['authordata'] = $author->data; 123 124 $link = get_the_author_posts_link(); 125 126 $url = sprintf( 'http://%1$s/?author=%2$s', WP_TESTS_DOMAIN, $author->ID ); 127 128 $this->assertContains( $url, $link ); 129 $this->assertContains( 'Posts by Foo', $link ); 130 $this->assertContains( '>Foo</a>', $link ); 131 132 unset( $GLOBALS['authordata'] ); 133 } 134 135 /** 136 * @ticket 30355 137 */ 138 public function test_get_the_author_posts_link_with_permalinks() { 139 global $wp_rewrite; 140 $wp_rewrite->init(); 141 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 142 $wp_rewrite->flush_rules(); 143 144 $author = $this->factory->user->create_and_get( array( 145 'display_name' => 'Foo', 146 'user_nicename' => 'bar' 147 ) ); 148 149 $GLOBALS['authordata'] = $author; 150 151 $link = get_the_author_posts_link(); 152 153 $url = sprintf( 'http://%1$s/author/%2$s/', WP_TESTS_DOMAIN, $author->user_nicename ); 154 155 $this->assertContains( $url, $link ); 156 $this->assertContains( 'Posts by Foo', $link ); 157 $this->assertContains( '>Foo</a>', $link ); 158 159 unset( $GLOBALS['authordata'] ); 160 } 161 102 162 }
Note: See TracChangeset
for help on using the changeset viewer.