Changeset 48937 for trunk/tests/phpunit/tests/theme.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme.php
r48858 r48937 50 50 $themes = wp_get_themes(); 51 51 $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] ); 52 $this->assert Equals( $this->theme_name, $themes[ $this->theme_slug ]->get( 'Name' ) );52 $this->assertSame( $this->theme_name, $themes[ $this->theme_slug ]->get( 'Name' ) ); 53 53 54 54 $single_theme = wp_get_theme( $this->theme_slug ); 55 $this->assert Equals( $single_theme->get( 'Name' ), $themes[ $this->theme_slug ]->get( 'Name' ) );55 $this->assertSame( $single_theme->get( 'Name' ), $themes[ $this->theme_slug ]->get( 'Name' ) ); 56 56 $this->assertEquals( $themes[ $this->theme_slug ], $single_theme ); 57 57 } … … 64 64 $themes = get_themes(); 65 65 $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] ); 66 $this->assert Equals( $themes[ $this->theme_name ], get_theme( $this->theme_name ) );67 68 $this->assert Equals( $this->theme_name, $themes[ $this->theme_name ]['Name'] );69 $this->assert Equals( $this->theme_name, $themes[ $this->theme_name ]->Name );70 $this->assert Equals( $this->theme_name, $themes[ $this->theme_name ]->name );66 $this->assertSame( $themes[ $this->theme_name ], get_theme( $this->theme_name ) ); 67 68 $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]['Name'] ); 69 $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]->Name ); 70 $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]->name ); 71 71 } 72 72 … … 82 82 $this->assertFalse( is_array( $theme ) ); 83 83 $this->assertInstanceOf( 'WP_Theme', $theme ); 84 $this->assert Equals( $theme, $themes[ $name ] );84 $this->assertSame( $theme, $themes[ $name ] ); 85 85 } 86 86 } … … 93 93 $_theme = wp_get_theme( $theme->get_stylesheet() ); 94 94 // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded). 95 $this->assert Equals( $theme->get( 'Name' ), $_theme->get( 'Name' ) );95 $this->assertSame( $theme->get( 'Name' ), $_theme->get( 'Name' ) ); 96 96 $this->assertEquals( $theme, $_theme ); 97 97 } … … 110 110 } 111 111 112 $this->assert Equals( $theme['Name'], $k );112 $this->assertSame( $theme['Name'], $k ); 113 113 $this->assertNotEmpty( $theme['Title'] ); 114 114 … … 163 163 $this->assertTrue( is_dir( $dir . $theme['Stylesheet Dir'] ) ); 164 164 165 $this->assert Equals( 'publish', $theme['Status'] );165 $this->assertSame( 'publish', $theme['Status'] ); 166 166 167 167 $this->assertTrue( is_file( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) ); … … 173 173 $theme = wp_get_theme( $this->theme_slug ); 174 174 175 $this->assert Equals( $this->theme_name, $theme->get( 'Name' ) );175 $this->assertSame( $this->theme_name, $theme->get( 'Name' ) ); 176 176 $this->assertNotEmpty( $theme->get( 'Description' ) ); 177 177 $this->assertNotEmpty( $theme->get( 'Author' ) ); … … 179 179 $this->assertNotEmpty( $theme->get( 'AuthorURI' ) ); 180 180 $this->assertNotEmpty( $theme->get( 'ThemeURI' ) ); 181 $this->assert Equals( $this->theme_slug, $theme->get_stylesheet() );182 $this->assert Equals( $this->theme_slug, $theme->get_template() );183 184 $this->assert Equals( 'publish', $theme->get( 'Status' ) );185 186 $this->assert Equals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_stylesheet_directory(), 'get_stylesheet_directory' );187 $this->assert Equals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_template_directory(), 'get_template_directory' );188 $this->assert Equals( content_url( 'themes/' . $this->theme_slug ), $theme->get_stylesheet_directory_uri(), 'get_stylesheet_directory_uri' );189 $this->assert Equals( content_url( 'themes/' . $this->theme_slug ), $theme->get_template_directory_uri(), 'get_template_directory_uri' );181 $this->assertSame( $this->theme_slug, $theme->get_stylesheet() ); 182 $this->assertSame( $this->theme_slug, $theme->get_template() ); 183 184 $this->assertSame( 'publish', $theme->get( 'Status' ) ); 185 186 $this->assertSame( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_stylesheet_directory(), 'get_stylesheet_directory' ); 187 $this->assertSame( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_template_directory(), 'get_template_directory' ); 188 $this->assertSame( content_url( 'themes/' . $this->theme_slug ), $theme->get_stylesheet_directory_uri(), 'get_stylesheet_directory_uri' ); 189 $this->assertSame( content_url( 'themes/' . $this->theme_slug ), $theme->get_template_directory_uri(), 'get_template_directory_uri' ); 190 190 } 191 191 … … 206 206 foreach ( $this->default_themes as $theme ) { 207 207 if ( wp_get_theme( $theme )->exists() ) { 208 $this->assert Equals( $theme, wp_get_theme( $theme )->get( 'TextDomain' ) );208 $this->assertSame( $theme, wp_get_theme( $theme )->get( 'TextDomain' ) ); 209 209 } 210 210 } … … 228 228 preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches ); 229 229 if ( $matches ) { 230 $this->assert Equals( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );230 $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); 231 231 } 232 232 233 233 preg_match( '#Copyright 20\d\d-(\d+) WordPress.org#', $readme, $matches ); 234 234 if ( $matches ) { 235 $this->assert Equals( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." );235 $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); 236 236 } 237 237 } … … 278 278 } 279 279 280 $this->assert Equals( $name, get_current_theme() );280 $this->assertSame( $name, get_current_theme() ); 281 281 282 282 // Make sure the various get_* functions return the correct values. 283 $this->assert Equals( $theme['Template'], get_template() );284 $this->assert Equals( $theme['Stylesheet'], get_stylesheet() );283 $this->assertSame( $theme['Template'], get_template() ); 284 $this->assertSame( $theme['Stylesheet'], get_stylesheet() ); 285 285 286 286 $root_fs = get_theme_root(); … … 290 290 $this->assertTrue( ! empty( $root_uri ) ); 291 291 292 $this->assert Equals( $root_fs . '/' . get_stylesheet(), get_stylesheet_directory() );293 $this->assert Equals( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() );294 $this->assert Equals( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() );295 // $this->assert Equals( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() );296 297 $this->assert Equals( $root_fs . '/' . get_template(), get_template_directory() );298 $this->assert Equals( $root_uri . '/' . get_template(), get_template_directory_uri() );292 $this->assertSame( $root_fs . '/' . get_stylesheet(), get_stylesheet_directory() ); 293 $this->assertSame( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() ); 294 $this->assertSame( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() ); 295 // $this->assertSame( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() ); 296 297 $this->assertSame( $root_fs . '/' . get_template(), get_template_directory() ); 298 $this->assertSame( $root_uri . '/' . get_template(), get_template_directory_uri() ); 299 299 300 300 // get_query_template() 301 301 302 302 // Template file that doesn't exist. 303 $this->assert Equals( '', get_query_template( rand_str() ) );303 $this->assertSame( '', get_query_template( rand_str() ) ); 304 304 305 305 // Template files that do exist. … … 308 308 $file = basename($path, '.php'); 309 309 FIXME: untestable because get_query_template() uses TEMPLATEPATH. 310 $this->assert Equals('', get_query_template($file));310 $this->assertSame('', get_query_template($file)); 311 311 } 312 312 */ 313 313 314 314 // These are kind of tautologies but at least exercise the code. 315 $this->assert Equals( get_404_template(), get_query_template( '404' ) );316 $this->assert Equals( get_archive_template(), get_query_template( 'archive' ) );317 $this->assert Equals( get_author_template(), get_query_template( 'author' ) );318 $this->assert Equals( get_category_template(), get_query_template( 'category' ) );319 $this->assert Equals( get_date_template(), get_query_template( 'date' ) );320 $this->assert Equals( get_home_template(), get_query_template( 'home', array( 'home.php', 'index.php' ) ) );321 $this->assert Equals( get_privacy_policy_template(), get_query_template( 'privacy_policy', array( 'privacy-policy.php' ) ) );322 $this->assert Equals( get_page_template(), get_query_template( 'page' ) );323 $this->assert Equals( get_search_template(), get_query_template( 'search' ) );324 $this->assert Equals( get_single_template(), get_query_template( 'single' ) );325 $this->assert Equals( get_attachment_template(), get_query_template( 'attachment' ) );326 327 $this->assert Equals( get_tag_template(), get_query_template( 'tag' ) );315 $this->assertSame( get_404_template(), get_query_template( '404' ) ); 316 $this->assertSame( get_archive_template(), get_query_template( 'archive' ) ); 317 $this->assertSame( get_author_template(), get_query_template( 'author' ) ); 318 $this->assertSame( get_category_template(), get_query_template( 'category' ) ); 319 $this->assertSame( get_date_template(), get_query_template( 'date' ) ); 320 $this->assertSame( get_home_template(), get_query_template( 'home', array( 'home.php', 'index.php' ) ) ); 321 $this->assertSame( get_privacy_policy_template(), get_query_template( 'privacy_policy', array( 'privacy-policy.php' ) ) ); 322 $this->assertSame( get_page_template(), get_query_template( 'page' ) ); 323 $this->assertSame( get_search_template(), get_query_template( 'search' ) ); 324 $this->assertSame( get_single_template(), get_query_template( 'single' ) ); 325 $this->assertSame( get_attachment_template(), get_query_template( 'attachment' ) ); 326 327 $this->assertSame( get_tag_template(), get_query_template( 'tag' ) ); 328 328 329 329 // nb: This probably doesn't run because WP_INSTALLING is defined. … … 341 341 342 342 $theme = wp_get_theme(); 343 $this->assert Equals( $style, (string) $theme );343 $this->assertSame( $style, (string) $theme ); 344 344 $this->assertNotFalse( $theme->errors() ); 345 345 $this->assertFalse( $theme->exists() ); 346 346 347 347 // These return the bogus name - perhaps not ideal behaviour? 348 $this->assert Equals( $template, get_template() );349 $this->assert Equals( $style, get_stylesheet() );348 $this->assertSame( $template, get_template() ); 349 $this->assertSame( $style, get_stylesheet() ); 350 350 } 351 351 … … 380 380 ) 381 381 ); 382 $this->assert Equals( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[0] )->post_date );383 $this->assert Equals( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[1] )->post_date );384 $this->assert Equals( 'auto-draft', get_post_status( $nav_created_post_ids[0] ) );385 $this->assert Equals( 'auto-draft', get_post_status( $nav_created_post_ids[1] ) );382 $this->assertSame( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[0] )->post_date ); 383 $this->assertSame( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[1] )->post_date ); 384 $this->assertSame( 'auto-draft', get_post_status( $nav_created_post_ids[0] ) ); 385 $this->assertSame( 'auto-draft', get_post_status( $nav_created_post_ids[1] ) ); 386 386 387 387 // Stubs transition to drafts when changeset is saved as a draft. … … 392 392 ) 393 393 ); 394 $this->assert Equals( 'draft', get_post_status( $nav_created_post_ids[0] ) );395 $this->assert Equals( 'draft', get_post_status( $nav_created_post_ids[1] ) );394 $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[0] ) ); 395 $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[1] ) ); 396 396 397 397 // Status remains unchanged for stub that the user broke out of the changeset. … … 408 408 ) 409 409 ); 410 $this->assert Equals( 'draft', get_post_status( $nav_created_post_ids[0] ) );411 $this->assert Equals( 'private', get_post_status( $nav_created_post_ids[1] ) );410 $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[0] ) ); 411 $this->assertSame( 'private', get_post_status( $nav_created_post_ids[1] ) ); 412 412 413 413 // Draft stub is trashed when the changeset is trashed. 414 414 $wp_customize->trash_changeset_post( $wp_customize->changeset_post_id() ); 415 $this->assert Equals( 'trash', get_post_status( $nav_created_post_ids[0] ) );416 $this->assert Equals( 'private', get_post_status( $nav_created_post_ids[1] ) );415 $this->assertSame( 'trash', get_post_status( $nav_created_post_ids[0] ) ); 416 $this->assertSame( 'private', get_post_status( $nav_created_post_ids[1] ) ); 417 417 } 418 418 … … 453 453 $actual = get_registered_theme_feature( 'test-feature' ); 454 454 455 $this->assert Equals( 'array', $actual['type'] );455 $this->assertSame( 'array', $actual['type'] ); 456 456 $this->assertTrue( $actual['variadic'] ); 457 $this->assert Equals( 'My Feature', $actual['description'] );458 $this->assert Equals( array( 'type' => 'string' ), $actual['show_in_rest']['schema']['items'] );457 $this->assertSame( 'My Feature', $actual['description'] ); 458 $this->assertSame( array( 'type' => 'string' ), $actual['show_in_rest']['schema']['items'] ); 459 459 } 460 460 … … 533 533 534 534 $actual = get_registered_theme_feature( 'test-feature' )['show_in_rest']['schema']['type']; 535 $this->assert Equals( 'array', $actual );535 $this->assertSame( 'array', $actual ); 536 536 } 537 537 … … 633 633 634 634 $this->assertWPError( $registered ); 635 $this->assert Equals( $error_code, $registered->get_error_code() );635 $this->assertSame( $error_code, $registered->get_error_code() ); 636 636 } 637 637
Note: See TracChangeset
for help on using the changeset viewer.