WordPress.org

Make WordPress Core

Changeset 435 in tests


Ignore:
Timestamp:
09/06/11 16:03:51 (3 years ago)
Author:
nacin
Message:

Add theme support tests (add_, current_, remove_). Includes tests for patch on #WP18548.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_theme.php

    r366 r435  
    361361    } 
    362362} 
     363 
     364class 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        #WP18548 
     416        if ( ! function_exists( '_wp_render_title_tag' ) ) 
     417            return; 
     418 
     419        // array of arguments, with the key of 'types' holding the post types. 
     420        add_theme_support( 'post-thumbnails', array( 'types' => array( 'post', 'page' ) ) ); 
     421        $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); 
     422        $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); 
     423        $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); 
     424        remove_theme_support( 'post-thumbnails' ); 
     425        $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); 
     426 
     427        // array of arguments, with the key of 'types' holding the post types. 
     428        add_theme_support( 'post-thumbnails', array( 'types' => true ) ); 
     429        $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); 
     430        $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type 
     431        remove_theme_support( 'post-thumbnails' ); 
     432        $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); 
     433 
     434        // array of arguments, with some other argument, and no 'types' argument. 
     435        add_theme_support( 'post-thumbnails', array( rand_str() => rand_str() ) ); 
     436        $this->assertTrue( current_theme_supports( 'post-thumbnails' ) ); 
     437        $this->assertTrue( current_theme_supports( 'post-thumbnails', rand_str() ) ); // any type 
     438        remove_theme_support( 'post-thumbnails' ); 
     439        $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); 
     440 
     441    } 
     442} 
    363443?> 
Note: See TracChangeset for help on using the changeset viewer.