WordPress.org

Make WordPress Core

Ticket #11611: 11611-unit.diff

File 11611-unit.diff, 1.0 KB (added by ryan, 2 years ago)

Unit tests

  • wp-testcase/test_includes_theme.php

     
    439439                $this->assertFalse( current_theme_supports( 'post-thumbnails' ) ); 
    440440 
    441441        } 
     442 
     443        function supports_foobar( $yesno, $args, $feature ) { 
     444                if ( $args[0] == $feature[0] ) 
     445                        return true; 
     446                return false; 
     447        } 
     448 
     449        function test_plugin_hook() { 
     450                $this->assertFalse( current_theme_supports( 'foobar' ) ); 
     451                add_theme_support( 'foobar' ); 
     452                $this->assertTrue( current_theme_supports( 'foobar' ) ); 
     453 
     454                add_filter( 'current_theme_supports-foobar', array( $this, 'supports_foobar'), 10, 3 ); 
     455 
     456                add_theme_support( 'foobar', 'bar' ); 
     457                $this->assertFalse( current_theme_supports( 'foobar', 'foo' ) ); 
     458                $this->assertTrue( current_theme_supports( 'foobar', 'bar' ) ); 
     459 
     460                remove_theme_support( 'foobar' ); 
     461                $this->assertFalse( current_theme_supports( 'foobar', 'bar' ) ); 
     462        } 
    442463} 
    443464?>