Changeset 35334
- Timestamp:
- 10/21/2015 04:54:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/general/document-title.php
r35329 r35334 8 8 */ 9 9 class Tests_General_DocumentTitle extends WP_UnitTestCase { 10 11 public $blog_name; 10 12 11 13 function setUp() { … … 34 36 ) ); 35 37 38 $this->blog_name = get_option( 'blogname' ); 39 36 40 setup_postdata( get_post( $this->post_id ) ); 37 41 } … … 46 50 } 47 51 52 function test__wp_render_title_tag() { 53 $this->go_to( '/' ); 54 55 $this->expectOutputString( sprintf( "<title>%s – %s</title>\n", $this->blog_name, get_option( 'blogdescription' ) ) ); 56 _wp_render_title_tag(); 57 } 58 59 function test__wp_render_title_no_theme_support() { 60 $this->go_to( '/' ); 61 62 remove_theme_support( 'title-tag' ); 63 64 $this->expectOutputString( '' ); 65 _wp_render_title_tag(); 66 } 67 48 68 function test_short_circuiting_title() { 49 69 $this->go_to( '/' ); … … 51 71 add_filter( 'pre_get_document_title', array( $this, '_short_circuit_title' ) ); 52 72 53 $this->expectOutputString( "<title>A Wild Title</title>\n" ); 54 _wp_render_title_tag(); 73 $this->assertEquals( 'A Wild Title', wp_get_document_title() ); 55 74 } 56 75 … … 66 85 $this->go_to( '/' ); 67 86 68 $this->expectOutputString( "<title>front-page – " . get_option( 'blogname' ) . "</title>\n" ); 69 _wp_render_title_tag(); 87 $this->assertEquals( sprintf( 'front-page – %s', $this->blog_name ), wp_get_document_title() ); 70 88 71 89 update_option( 'show_on_front', 'posts' ); … … 77 95 add_filter( 'document_title_parts', array( $this, '_home_title_parts' ) ); 78 96 79 $this->expectOutputString( "<title>" . get_option( 'blogname' ) . " – Just another WordPress site</title>\n" ); 80 _wp_render_title_tag(); 97 $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); 81 98 } 82 99 … … 94 111 add_filter( 'document_title_parts', array( $this, '_paged_title_parts' ) ); 95 112 96 $this->expectOutputString( "<title>" . get_option( 'blogname' ) . " – Page 4 – Just another WordPress site</title>\n" ); 97 _wp_render_title_tag(); 113 $this->assertEquals( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); 98 114 } 99 115 … … 112 128 add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) ); 113 129 114 $this->expectOutputString( "<title>test_title – " . get_option( 'blogname' ) . "</title>\n" ); 115 _wp_render_title_tag(); 130 $this->assertEquals( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() ); 116 131 } 117 132 … … 127 142 $this->go_to( '?cat=' . $this->category_id ); 128 143 129 $this->expectOutputString( "<title>test_category – " . get_option( 'blogname' ) . "</title>\n" ); 130 _wp_render_title_tag(); 144 $this->assertEquals( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() ); 131 145 } 132 146 … … 134 148 $this->go_to( '?s=test_title' ); 135 149 136 $this->expectOutputString( "<title>Search Results for “test_title” – " . get_option( 'blogname' ) . "</title>\n" ); 137 _wp_render_title_tag(); 150 $this->assertEquals( sprintf( 'Search Results for “test_title” – %s', $this->blog_name ), wp_get_document_title() ); 138 151 } 139 152 … … 141 154 $this->go_to( '?author=' . $this->author_id ); 142 155 143 $this->expectOutputString( "<title>test_author – " . get_option( 'blogname' ) . "</title>\n" ); 144 _wp_render_title_tag(); 156 $this->assertEquals( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() ); 145 157 } 146 158 … … 160 172 $this->go_to( '?post_type=cpt' ); 161 173 162 $this->expectOutputString( "<title>test_cpt – " . get_option( 'blogname' ) . "</title>\n" ); 163 _wp_render_title_tag(); 174 $this->assertEquals( sprintf( 'test_cpt – %s', $this->blog_name ), wp_get_document_title() ); 164 175 } 165 176 … … 167 178 $this->go_to( '?year=2015' ); 168 179 169 $this->expectOutputString( "<title>2015 – " . get_option( 'blogname' ) . "</title>\n" ); 170 _wp_render_title_tag(); 180 $this->assertEquals( sprintf( '2015 – %s', $this->blog_name ), wp_get_document_title() ); 171 181 } 172 182 … … 174 184 $this->go_to( '?monthnum=09' ); 175 185 176 $this->expectOutputString( "<title>September 2015 – " . get_option( 'blogname' ) . "</title>\n" ); 177 _wp_render_title_tag(); 186 $this->assertEquals( sprintf( 'September 2015 – %s', $this->blog_name ), wp_get_document_title() ); 178 187 } 179 188 … … 181 190 $this->go_to( '?day=22' ); 182 191 183 $this->expectOutputString( "<title>September 22, 2015 – " . get_option( 'blogname' ) . "</title>\n" ); 184 _wp_render_title_tag(); 192 $this->assertEquals( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() ); 185 193 } 186 194 … … 188 196 $this->go_to( '?m=404' ); 189 197 190 $this->expectOutputString( "<title>Page not found – " . get_option( 'blogname' ) . "</title>\n" ); 191 _wp_render_title_tag(); 198 $this->assertEquals( sprintf( 'Page not found – %s', $this->blog_name ), wp_get_document_title() ); 192 199 } 193 200 … … 197 204 add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) ); 198 205 199 $this->expectOutputString( "<title>test_title – Page 4 – " . get_option( 'blogname' ) . "</title>\n" ); 200 _wp_render_title_tag(); 206 $this->assertEquals( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() ); 201 207 } 202 208 … … 215 221 add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) ); 216 222 217 $this->expectOutputString( "<title>" . get_option( 'blogname' ) . " – test_title</title>\n" ); 218 _wp_render_title_tag(); 223 $this->assertEquals( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() ); 219 224 } 220 225 … … 233 238 add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) ); 234 239 235 $this->expectOutputString( "<title>test_title %% " . get_option( 'blogname' ) . "</title>\n" ); 236 _wp_render_title_tag(); 240 $this->assertEquals( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() ); 237 241 } 238 242
Note: See TracChangeset
for help on using the changeset viewer.