- Timestamp:
- 11/04/2021 03:22:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/general/wpGetDocumentTitle.php
r51568 r52010 44 44 } 45 45 46 function set_up() {46 public function set_up() { 47 47 parent::set_up(); 48 48 49 add_action( 'after_setup_theme', array( $this, ' _add_title_tag_support' ) );49 add_action( 'after_setup_theme', array( $this, 'add_title_tag_support' ) ); 50 50 51 51 $this->blog_name = get_option( 'blogname' ); … … 54 54 } 55 55 56 function _add_title_tag_support() {56 public function add_title_tag_support() { 57 57 add_theme_support( 'title-tag' ); 58 58 } 59 59 60 function test__wp_render_title_tag() {60 public function test__wp_render_title_tag() { 61 61 $this->go_to( '/' ); 62 62 … … 65 65 } 66 66 67 function test__wp_render_title_no_theme_support() {67 public function test__wp_render_title_no_theme_support() { 68 68 $this->go_to( '/' ); 69 69 … … 74 74 } 75 75 76 function test_short_circuiting_title() {77 $this->go_to( '/' ); 78 79 add_filter( 'pre_get_document_title', array( $this, ' _short_circuit_title' ) );76 public function test_short_circuiting_title() { 77 $this->go_to( '/' ); 78 79 add_filter( 'pre_get_document_title', array( $this, 'short_circuit_title' ) ); 80 80 81 81 $this->assertSame( 'A Wild Title', wp_get_document_title() ); 82 82 } 83 83 84 function _short_circuit_title( $title ) {84 public function short_circuit_title( $title ) { 85 85 return 'A Wild Title'; 86 86 } 87 87 88 function test_front_page_title() {88 public function test_front_page_title() { 89 89 update_option( 'show_on_front', 'page' ); 90 90 update_option( … … 97 97 ) 98 98 ); 99 add_filter( 'document_title_parts', array( $this, ' _front_page_title_parts' ) );99 add_filter( 'document_title_parts', array( $this, 'front_page_title_parts' ) ); 100 100 101 101 $this->go_to( '/' ); … … 108 108 } 109 109 110 function _front_page_title_parts( $parts ) {110 public function front_page_title_parts( $parts ) { 111 111 $this->assertArrayHasKey( 'title', $parts ); 112 112 $this->assertArrayHasKey( 'tagline', $parts ); … … 116 116 } 117 117 118 function test_home_title() {118 public function test_home_title() { 119 119 $blog_page_id = $this->factory->post->create( 120 120 array( … … 131 131 } 132 132 133 function test_paged_title() {133 public function test_paged_title() { 134 134 $this->go_to( '?page=4' ); 135 135 136 add_filter( 'document_title_parts', array( $this, ' _paged_title_parts' ) );136 add_filter( 'document_title_parts', array( $this, 'paged_title_parts' ) ); 137 137 138 138 $this->assertSame( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); 139 139 } 140 140 141 function _paged_title_parts( $parts ) {141 public function paged_title_parts( $parts ) { 142 142 $this->assertArrayHasKey( 'page', $parts ); 143 143 $this->assertArrayHasKey( 'title', $parts ); … … 148 148 } 149 149 150 function test_singular_title() {150 public function test_singular_title() { 151 151 $this->go_to( '?p=' . self::$post_id ); 152 152 153 add_filter( 'document_title_parts', array( $this, ' _singular_title_parts' ) );153 add_filter( 'document_title_parts', array( $this, 'singular_title_parts' ) ); 154 154 155 155 $this->assertSame( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() ); 156 156 } 157 157 158 function _singular_title_parts( $parts ) {158 public function singular_title_parts( $parts ) { 159 159 $this->assertArrayHasKey( 'site', $parts ); 160 160 $this->assertArrayHasKey( 'title', $parts ); … … 164 164 } 165 165 166 function test_category_title() {166 public function test_category_title() { 167 167 $this->go_to( '?cat=' . self::$category_id ); 168 168 … … 170 170 } 171 171 172 function test_search_title() {172 public function test_search_title() { 173 173 $this->go_to( '?s=test_title' ); 174 174 … … 176 176 } 177 177 178 function test_author_title() {178 public function test_author_title() { 179 179 $this->go_to( '?author=' . self::$author_id ); 180 180 … … 182 182 } 183 183 184 function test_post_type_archive_title() {184 public function test_post_type_archive_title() { 185 185 register_post_type( 186 186 'cpt', … … 205 205 } 206 206 207 function test_year_title() {207 public function test_year_title() { 208 208 $this->go_to( '?year=2015' ); 209 209 … … 211 211 } 212 212 213 function test_month_title() {213 public function test_month_title() { 214 214 $this->go_to( '?monthnum=09' ); 215 215 … … 217 217 } 218 218 219 function test_day_title() {219 public function test_day_title() { 220 220 $this->go_to( '?day=22' ); 221 221 … … 223 223 } 224 224 225 function test_404_title() {225 public function test_404_title() { 226 226 $this->go_to( '?m=404' ); 227 227 … … 229 229 } 230 230 231 function test_paged_post_title() {231 public function test_paged_post_title() { 232 232 $this->go_to( '?paged=4&p=' . self::$post_id ); 233 233 234 add_filter( 'title_tag_parts', array( $this, ' _paged_post_title_parts' ) );234 add_filter( 'title_tag_parts', array( $this, 'paged_post_title_parts' ) ); 235 235 236 236 $this->assertSame( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() ); 237 237 } 238 238 239 function _paged_post_title_parts( $parts ) {239 public function paged_post_title_parts( $parts ) { 240 240 $this->assertArrayHasKey( 'page', $parts ); 241 241 $this->assertArrayHasKey( 'site', $parts ); … … 246 246 } 247 247 248 function test_rearrange_title_parts() {248 public function test_rearrange_title_parts() { 249 249 $this->go_to( '?p=' . self::$post_id ); 250 250 251 add_filter( 'document_title_parts', array( $this, ' _rearrange_title_parts' ) );251 add_filter( 'document_title_parts', array( $this, 'rearrange_title_parts' ) ); 252 252 253 253 $this->assertSame( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() ); 254 254 } 255 255 256 function _rearrange_title_parts( $parts ) {256 public function rearrange_title_parts( $parts ) { 257 257 $parts = array( 258 258 $parts['site'], … … 263 263 } 264 264 265 function test_change_title_separator() {265 public function test_change_title_separator() { 266 266 $this->go_to( '?p=' . self::$post_id ); 267 267 268 add_filter( 'document_title_separator', array( $this, ' _change_title_separator' ) );268 add_filter( 'document_title_separator', array( $this, 'change_title_separator' ) ); 269 269 270 270 $this->assertSame( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() ); 271 271 } 272 272 273 function _change_title_separator( $sep ) {273 public function change_title_separator( $sep ) { 274 274 return '%%'; 275 275 }
Note: See TracChangeset
for help on using the changeset viewer.