| 1 | Index: wp-testcase/test_includes_theme.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-testcase/test_includes_theme.php (revision 422) |
|---|
| 4 | +++ wp-testcase/test_includes_theme.php (working copy) |
|---|
| 5 | @@ -360,4 +360,80 @@ |
|---|
| 6 | $this->assertLessThanOrEqual(261998, strlen(serialize($themes))); |
|---|
| 7 | } |
|---|
| 8 | } |
|---|
| 9 | + |
|---|
| 10 | +class TestThemeSupport extends WPTestCase { |
|---|
| 11 | + function setUp() { |
|---|
| 12 | + parent::setUp(); |
|---|
| 13 | + } |
|---|
| 14 | + |
|---|
| 15 | + function tearDown() { |
|---|
| 16 | + parent::tearDown(); |
|---|
| 17 | + } |
|---|
| 18 | + |
|---|
| 19 | + function test_the_basics() { |
|---|
| 20 | + $this->assertFalse( current_theme_supports( 'automatic-feed-links' ) ); |
|---|
| 21 | + add_theme_support( 'automatic-feed-links' ); |
|---|
| 22 | + $this->assertTrue( current_theme_supports( 'automatic-feed-links' ) ); |
|---|
| 23 | + remove_theme_support( 'automatic-feed-links' ); |
|---|
| 24 | + $this->assertFalse( current_theme_supports( 'automatic-feed-links' ) ); |
|---|
| 25 | + } |
|---|
| 26 | + |
|---|
| 27 | + function test_admin_bar() { |
|---|
| 28 | + $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
|---|
| 29 | + add_theme_support( 'admin-bar' ); |
|---|
| 30 | + $this->assertTrue( current_theme_supports( 'admin-bar' ) ); |
|---|
| 31 | + remove_theme_support( 'admin-bar' ); |
|---|
| 32 | + $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
|---|
| 33 | + |
|---|
| 34 | + add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) ); |
|---|
| 35 | + $this->assertTrue( current_theme_supports( 'admin-bar' ) ); |
|---|
| 36 | + |
|---|
| 37 | + $this->assertEquals( |
|---|
| 38 | + array( 0 => array( 'callback' => '__return_false' ) ), |
|---|
| 39 | + get_theme_support( 'admin-bar' ) |
|---|
| 40 | + ); |
|---|
| 41 | + remove_theme_support( 'admin-bar' ); |
|---|
| 42 | + $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
|---|
| 43 | + $this->assertFalse( get_theme_support( 'admin-bar' ) ); |
|---|
| 44 | + } |
|---|
| 45 | + |
|---|
| 46 | + function test_post_thumbnails() { |
|---|
| 47 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 48 | + add_theme_support( 'post-thumbnails' ); |
|---|
| 49 | + $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 50 | + remove_theme_support( 'post-thumbnails' ); |
|---|
| 51 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 52 | + |
|---|
| 53 | + // simple array of post types. |
|---|
| 54 | + add_theme_support( 'post-thumbnails', array( 'post', 'page' ) ); |
|---|
| 55 | + $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 56 | + $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); |
|---|
| 57 | + $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); |
|---|
| 58 | + remove_theme_support( 'post-thumbnails' ); |
|---|
| 59 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 60 | + |
|---|
| 61 | + // array of arguments, with the key of 'types' holding the post types. |
|---|
| 62 | + add_theme_support( 'post-thumbnails', array( 'types' => array( 'post', 'page' ) ) ); |
|---|
| 63 | + $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 64 | + $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); |
|---|
| 65 | + $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); |
|---|
| 66 | + remove_theme_support( 'post-thumbnails' ); |
|---|
| 67 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 68 | + |
|---|
| 69 | + // array of arguments, with the key of 'types' holding the post types. |
|---|
| 70 | + add_theme_support( 'post-thumbnails', array( 'types' => true ) ); |
|---|
| 71 | + $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 72 | + $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type |
|---|
| 73 | + remove_theme_support( 'post-thumbnails' ); |
|---|
| 74 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 75 | + |
|---|
| 76 | + // array of arguments, with some other argument, and no 'types' argument. |
|---|
| 77 | + add_theme_support( 'post-thumbnails', array( rand_str() => rand_str() ) ); |
|---|
| 78 | + $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 79 | + $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type |
|---|
| 80 | + remove_theme_support( 'post-thumbnails' ); |
|---|
| 81 | + $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
|---|
| 82 | + |
|---|
| 83 | + } |
|---|
| 84 | +} |
|---|
| 85 | ?> |
|---|