Changeset 52010 for trunk/tests/phpunit/tests/general/template.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/general/template.php
r51586 r52010 18 18 public $custom_logo_url; 19 19 20 function set_up() {20 public function set_up() { 21 21 parent::set_up(); 22 22 … … 24 24 } 25 25 26 function tear_down() {26 public function tear_down() { 27 27 global $wp_customize; 28 $this-> _remove_custom_logo();29 $this-> _remove_site_icon();28 $this->remove_custom_logo(); 29 $this->remove_site_icon(); 30 30 $wp_customize = null; 31 31 … … 38 38 * @requires function imagejpeg 39 39 */ 40 function test_get_site_icon_url() {40 public function test_get_site_icon_url() { 41 41 $this->assertEmpty( get_site_icon_url() ); 42 42 43 $this-> _set_site_icon();43 $this->set_site_icon(); 44 44 $this->assertSame( $this->site_icon_url, get_site_icon_url() ); 45 45 46 $this-> _remove_site_icon();46 $this->remove_site_icon(); 47 47 $this->assertEmpty( get_site_icon_url() ); 48 48 } … … 53 53 * @requires function imagejpeg 54 54 */ 55 function test_site_icon_url() {55 public function test_site_icon_url() { 56 56 $this->expectOutputString( '' ); 57 57 site_icon_url(); 58 58 59 $this-> _set_site_icon();59 $this->set_site_icon(); 60 60 $this->expectOutputString( $this->site_icon_url ); 61 61 site_icon_url(); … … 67 67 * @requires function imagejpeg 68 68 */ 69 function test_has_site_icon() {69 public function test_has_site_icon() { 70 70 $this->assertFalse( has_site_icon() ); 71 71 72 $this-> _set_site_icon();72 $this->set_site_icon(); 73 73 $this->assertTrue( has_site_icon() ); 74 74 75 $this-> _remove_site_icon();75 $this->remove_site_icon(); 76 76 $this->assertFalse( has_site_icon() ); 77 77 } … … 83 83 * @covers ::has_site_icon 84 84 */ 85 function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() {85 public function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { 86 86 $blog_id = $this->factory->blog->create(); 87 87 switch_to_blog( $blog_id ); 88 $this-> _set_site_icon();88 $this->set_site_icon(); 89 89 restore_current_blog(); 90 90 … … 98 98 * @covers ::has_site_icon 99 99 */ 100 function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() {100 public function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { 101 101 $blog_id = $this->factory->blog->create(); 102 102 … … 109 109 * @requires function imagejpeg 110 110 */ 111 function test_wp_site_icon() {111 public function test_wp_site_icon() { 112 112 $this->expectOutputString( '' ); 113 113 wp_site_icon(); 114 114 115 $this-> _set_site_icon();115 $this->set_site_icon(); 116 116 $output = array( 117 117 sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( get_site_icon_url( 32 ) ) ), … … 132 132 * @requires function imagejpeg 133 133 */ 134 function test_wp_site_icon_with_filter() {134 public function test_wp_site_icon_with_filter() { 135 135 $this->expectOutputString( '' ); 136 136 wp_site_icon(); 137 137 138 $this-> _set_site_icon();138 $this->set_site_icon(); 139 139 $output = array( 140 140 sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( get_site_icon_url( 32 ) ) ), … … 148 148 149 149 $this->expectOutputString( $output ); 150 add_filter( 'site_icon_meta_tags', array( $this, ' _custom_site_icon_meta_tag' ) );150 add_filter( 'site_icon_meta_tags', array( $this, 'custom_site_icon_meta_tag' ) ); 151 151 wp_site_icon(); 152 remove_filter( 'site_icon_meta_tags', array( $this, ' _custom_site_icon_meta_tag' ) );152 remove_filter( 'site_icon_meta_tags', array( $this, 'custom_site_icon_meta_tag' ) ); 153 153 } 154 154 … … 158 158 * @covers ::wp_site_icon 159 159 */ 160 function test_customize_preview_wp_site_icon_empty() {160 public function test_customize_preview_wp_site_icon_empty() { 161 161 global $wp_customize; 162 162 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); … … 176 176 * @covers ::wp_site_icon 177 177 */ 178 function test_customize_preview_wp_site_icon_dirty() {178 public function test_customize_preview_wp_site_icon_dirty() { 179 179 global $wp_customize; 180 180 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); … … 185 185 $wp_customize->start_previewing_theme(); 186 186 187 $attachment_id = $this-> _insert_attachment();187 $attachment_id = $this->insert_attachment(); 188 188 $wp_customize->set_post_value( 'site_icon', $attachment_id ); 189 189 $wp_customize->get_setting( 'site_icon' )->preview(); … … 208 208 * @return array 209 209 */ 210 function _custom_site_icon_meta_tag( $meta_tags ) {210 public function custom_site_icon_meta_tag( $meta_tags ) { 211 211 $meta_tags[] = sprintf( '<link rel="apple-touch-icon" sizes="150x150" href="%s" />', esc_url( get_site_icon_url( 150 ) ) ); 212 212 … … 219 219 * @since 4.3.0 220 220 */ 221 function _set_site_icon() {221 private function set_site_icon() { 222 222 if ( ! $this->site_icon_id ) { 223 223 add_filter( 'intermediate_image_sizes_advanced', array( $this->wp_site_icon, 'additional_sizes' ) ); 224 $this-> _insert_attachment();224 $this->insert_attachment(); 225 225 remove_filter( 'intermediate_image_sizes_advanced', array( $this->wp_site_icon, 'additional_sizes' ) ); 226 226 } … … 234 234 * @since 4.3.0 235 235 */ 236 function _remove_site_icon() {236 private function remove_site_icon() { 237 237 delete_option( 'site_icon' ); 238 238 } … … 243 243 * @since 4.3.0 244 244 */ 245 function _insert_attachment() {245 private function insert_attachment() { 246 246 $filename = DIR_TESTDATA . '/images/test-image.jpg'; 247 247 $contents = file_get_contents( $filename ); … … 261 261 * @since 4.5.0 262 262 */ 263 function test_has_custom_logo() {263 public function test_has_custom_logo() { 264 264 $this->assertFalse( has_custom_logo() ); 265 265 266 $this-> _set_custom_logo();266 $this->set_custom_logo(); 267 267 $this->assertTrue( has_custom_logo() ); 268 268 269 $this-> _remove_custom_logo();269 $this->remove_custom_logo(); 270 270 $this->assertFalse( has_custom_logo() ); 271 271 } … … 277 277 * @covers ::has_custom_logo 278 278 */ 279 function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() {279 public function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { 280 280 $blog_id = $this->factory->blog->create(); 281 281 switch_to_blog( $blog_id ); 282 $this-> _set_custom_logo();282 $this->set_custom_logo(); 283 283 restore_current_blog(); 284 284 … … 292 292 * @covers ::has_custom_logo 293 293 */ 294 function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() {294 public function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { 295 295 $blog_id = $this->factory->blog->create(); 296 296 … … 304 304 * @since 4.5.0 305 305 */ 306 function test_get_custom_logo() {306 public function test_get_custom_logo() { 307 307 $this->assertEmpty( get_custom_logo() ); 308 308 309 $this-> _set_custom_logo();309 $this->set_custom_logo(); 310 310 $custom_logo = get_custom_logo(); 311 311 $this->assertNotEmpty( $custom_logo ); 312 312 $this->assertIsString( $custom_logo ); 313 313 314 $this-> _remove_custom_logo();314 $this->remove_custom_logo(); 315 315 $this->assertEmpty( get_custom_logo() ); 316 316 } … … 322 322 * @covers ::get_custom_logo 323 323 */ 324 function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() {324 public function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { 325 325 $blog_id = $this->factory->blog->create(); 326 326 switch_to_blog( $blog_id ); 327 327 328 $this-> _set_custom_logo();328 $this->set_custom_logo(); 329 329 330 330 $custom_logo_attr = array( … … 353 353 * @since 4.5.0 354 354 */ 355 function test_the_custom_logo() {355 public function test_the_custom_logo() { 356 356 $this->expectOutputString( '' ); 357 357 the_custom_logo(); 358 358 359 $this-> _set_custom_logo();359 $this->set_custom_logo(); 360 360 361 361 $custom_logo_attr = array( … … 381 381 * @covers ::the_custom_logo 382 382 */ 383 function test_the_custom_logo_with_alt() {384 $this-> _set_custom_logo();383 public function test_the_custom_logo_with_alt() { 384 $this->set_custom_logo(); 385 385 386 386 $image_alt = 'My alt attribute'; … … 407 407 * @since 4.5.0 408 408 */ 409 function _set_custom_logo() {409 private function set_custom_logo() { 410 410 if ( ! $this->custom_logo_id ) { 411 $this-> _insert_custom_logo();411 $this->insert_custom_logo(); 412 412 } 413 413 … … 420 420 * @since 4.5.0 421 421 */ 422 function _remove_custom_logo() {422 private function remove_custom_logo() { 423 423 remove_theme_mod( 'custom_logo' ); 424 424 } … … 429 429 * @since 4.5.0 430 430 */ 431 function _insert_custom_logo() {431 private function insert_custom_logo() { 432 432 $filename = DIR_TESTDATA . '/images/test-image.jpg'; 433 433 $contents = file_get_contents( $filename ); … … 445 445 * @covers ::get_site_icon_url 446 446 */ 447 function test_get_site_icon_url_preserves_switched_state() {447 public function test_get_site_icon_url_preserves_switched_state() { 448 448 $blog_id = $this->factory->blog->create(); 449 449 switch_to_blog( $blog_id ); … … 465 465 * @covers ::has_custom_logo 466 466 */ 467 function test_has_custom_logo_preserves_switched_state() {467 public function test_has_custom_logo_preserves_switched_state() { 468 468 $blog_id = $this->factory->blog->create(); 469 469 switch_to_blog( $blog_id ); … … 485 485 * @covers ::get_custom_logo 486 486 */ 487 function test_get_custom_logo_preserves_switched_state() {487 public function test_get_custom_logo_preserves_switched_state() { 488 488 $blog_id = $this->factory->blog->create(); 489 489 switch_to_blog( $blog_id ); … … 505 505 * @covers ::get_header 506 506 */ 507 function test_get_header_returns_nothing_on_success() {507 public function test_get_header_returns_nothing_on_success() { 508 508 $this->expectOutputRegex( '/Header/' ); 509 509 … … 518 518 * @covers ::get_footer 519 519 */ 520 function test_get_footer_returns_nothing_on_success() {520 public function test_get_footer_returns_nothing_on_success() { 521 521 $this->expectOutputRegex( '/Footer/' ); 522 522 … … 531 531 * @covers ::get_sidebar 532 532 */ 533 function test_get_sidebar_returns_nothing_on_success() {533 public function test_get_sidebar_returns_nothing_on_success() { 534 534 $this->expectOutputRegex( '/Sidebar/' ); 535 535 … … 544 544 * @covers ::get_template_part 545 545 */ 546 function test_get_template_part_returns_nothing_on_success() {546 public function test_get_template_part_returns_nothing_on_success() { 547 547 $this->expectOutputRegex( '/Template Part/' ); 548 548 … … 557 557 * @covers ::get_template_part 558 558 */ 559 function test_get_template_part_returns_false_on_failure() {559 public function test_get_template_part_returns_false_on_failure() { 560 560 $this->assertFalse( get_template_part( 'non-existing-template' ) ); 561 561 } … … 566 566 * @covers ::get_template_part 567 567 */ 568 function test_get_template_part_passes_arguments_to_template() {568 public function test_get_template_part_passes_arguments_to_template() { 569 569 $this->expectOutputRegex( '/{"foo":"baz"}/' ); 570 570 … … 577 577 * @covers ::get_the_archive_title 578 578 */ 579 function test_get_the_archive_title_is_correct_for_author_queries() {579 public function test_get_the_archive_title_is_correct_for_author_queries() { 580 580 $user_with_posts = $this->factory()->user->create_and_get( 581 581 array(
Note: See TracChangeset
for help on using the changeset viewer.