| 363 | |
| 364 | class TestThemeSupport extends WPTestCase { |
| 365 | function setUp() { |
| 366 | parent::setUp(); |
| 367 | } |
| 368 | |
| 369 | function tearDown() { |
| 370 | parent::tearDown(); |
| 371 | } |
| 372 | |
| 373 | function test_the_basics() { |
| 374 | $this->assertFalse( current_theme_supports( 'automatic-feed-links' ) ); |
| 375 | add_theme_support( 'automatic-feed-links' ); |
| 376 | $this->assertTrue( current_theme_supports( 'automatic-feed-links' ) ); |
| 377 | remove_theme_support( 'automatic-feed-links' ); |
| 378 | $this->assertFalse( current_theme_supports( 'automatic-feed-links' ) ); |
| 379 | } |
| 380 | |
| 381 | function test_admin_bar() { |
| 382 | $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
| 383 | add_theme_support( 'admin-bar' ); |
| 384 | $this->assertTrue( current_theme_supports( 'admin-bar' ) ); |
| 385 | remove_theme_support( 'admin-bar' ); |
| 386 | $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
| 387 | |
| 388 | add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) ); |
| 389 | $this->assertTrue( current_theme_supports( 'admin-bar' ) ); |
| 390 | |
| 391 | $this->assertEquals( |
| 392 | array( 0 => array( 'callback' => '__return_false' ) ), |
| 393 | get_theme_support( 'admin-bar' ) |
| 394 | ); |
| 395 | remove_theme_support( 'admin-bar' ); |
| 396 | $this->assertFalse( current_theme_supports( 'admin-bar' ) ); |
| 397 | $this->assertFalse( get_theme_support( 'admin-bar' ) ); |
| 398 | } |
| 399 | |
| 400 | function test_post_thumbnails() { |
| 401 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 402 | add_theme_support( 'post-thumbnails' ); |
| 403 | $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
| 404 | remove_theme_support( 'post-thumbnails' ); |
| 405 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 406 | |
| 407 | // simple array of post types. |
| 408 | add_theme_support( 'post-thumbnails', array( 'post', 'page' ) ); |
| 409 | $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
| 410 | $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); |
| 411 | $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); |
| 412 | remove_theme_support( 'post-thumbnails' ); |
| 413 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 414 | |
| 415 | // array of arguments, with the key of 'types' holding the post types. |
| 416 | add_theme_support( 'post-thumbnails', array( 'types' => array( 'post', 'page' ) ) ); |
| 417 | $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
| 418 | $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); |
| 419 | $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); |
| 420 | remove_theme_support( 'post-thumbnails' ); |
| 421 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 422 | |
| 423 | // array of arguments, with the key of 'types' holding the post types. |
| 424 | add_theme_support( 'post-thumbnails', array( 'types' => true ) ); |
| 425 | $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
| 426 | $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type |
| 427 | remove_theme_support( 'post-thumbnails' ); |
| 428 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 429 | |
| 430 | // array of arguments, with some other argument, and no 'types' argument. |
| 431 | add_theme_support( 'post-thumbnails', array( rand_str() => rand_str() ) ); |
| 432 | $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); |
| 433 | $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type |
| 434 | remove_theme_support( 'post-thumbnails' ); |
| 435 | $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); |
| 436 | |
| 437 | } |
| 438 | } |