From 262150a91ee65c6b72c4572e126307cd468cbd37 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 1 Nov 2014 04:00:59 +0000 Subject: [PATCH] Clean up 'post-thumbnail' theme support unit tests. * Separate into smaller test methods. * Remove incorrect tests. A number of assertions in the existing test have always incorrectly described the behavior of `current_theme_supports( 'post-thumbnails' )`, but no one ever noticed because the tests had been designed to bail when `_wp_render_title_tag()` did not exist. The failures finally became visible when that function was introduced in [30074]. See #18548. git-svn-id: https://develop.svn.wordpress.org/trunk@30148 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/theme/support.php | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/tests/theme/support.php b/tests/phpunit/tests/theme/support.php index 10d8298668..c5669f8f5b 100644 --- a/tests/phpunit/tests/theme/support.php +++ b/tests/phpunit/tests/theme/support.php @@ -34,48 +34,31 @@ class Tests_Theme_Support extends WP_UnitTestCase { $this->assertFalse( get_theme_support( 'admin-bar' ) ); } - function test_post_thumbnails() { + public function test_post_thumbnails() { add_theme_support( 'post-thumbnails' ); $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); remove_theme_support( 'post-thumbnails' ); $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); add_theme_support( 'post-thumbnails' ); $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); + } - // simple array of post types. + public function test_post_thumbnails_flat_array_of_post_types() { add_theme_support( 'post-thumbnails', array( 'post', 'page' ) ); $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); remove_theme_support( 'post-thumbnails' ); $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); + } - #WP18548 - if ( ! function_exists( '_wp_render_title_tag' ) ) - return; - - // array of arguments, with the key of 'types' holding the post types. - add_theme_support( 'post-thumbnails', array( 'types' => array( 'post', 'page' ) ) ); - $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); - $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); - $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); - remove_theme_support( 'post-thumbnails' ); - $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); - + public function test_post_thumbnails_types_true() { // array of arguments, with the key of 'types' holding the post types. add_theme_support( 'post-thumbnails', array( 'types' => true ) ); $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type remove_theme_support( 'post-thumbnails' ); $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); - - // array of arguments, with some other argument, and no 'types' argument. - add_theme_support( 'post-thumbnails', array( rand_str() => rand_str() ) ); - $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); - $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type - remove_theme_support( 'post-thumbnails' ); - $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); - } /**