WordPress.org

Make WordPress Core

Ticket #42298: 42298.diff

File 42298.diff, 3.2 KB (added by birgire, 4 years ago)
  • tests/phpunit/tests/theme.php

    diff --git tests/phpunit/tests/theme.php tests/phpunit/tests/theme.php
    index 3238f6e..895ecf8 100644
    class Tests_Theme extends WP_UnitTestCase { 
    4848                $this->assertEquals( $themes[ $this->theme_slug ], $single_theme );
    4949        }
    5050
    51         /**
    52          * @expectedDeprecated get_theme
    53          * @expectedDeprecated get_themes
    54          */
    5551        function test_get_themes_default() {
    56                 $themes = get_themes();
    57                 $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] );
    58                 $this->assertEquals( $themes[ $this->theme_name ], get_theme( $this->theme_name ) );
     52                $themes = wp_get_themes();
     53                $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] );
     54                $this->assertEquals( $themes[ $this->theme_slug ], wp_get_theme( $this->theme_slug )->get( 'Name' ) );
     55
     56                $this->assertEquals( $this->theme_name, $themes[ $this->theme_slug ]['Name'] );
     57                $this->assertEquals( $this->theme_name, $themes[ $this->theme_slug ]->Name );
     58                $this->assertEquals( $this->theme_name, $themes[ $this->theme_slug ]->name );
    5959
    60                 $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]['Name'] );
    61                 $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->Name );
    62                 $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->name );
    6360        }
    6461
    65         /**
    66          * @expectedDeprecated get_theme
    67          * @expectedDeprecated get_themes
    68          */
    6962        function test_get_theme() {
    70                 $themes = get_themes();
     63                $themes = wp_get_themes();
    7164                foreach (array_keys($themes) as $name) {
    72                         $theme = get_theme($name);
     65                        $theme = wp_get_theme($name);
    7366                        // WP_Theme implements ArrayAccess. Even ArrayObject returns false for is_array().
    7467                        $this->assertFalse( is_array( $theme ) );
    7568                        $this->assertInstanceOf( 'WP_Theme', $theme );
    class Tests_Theme extends WP_UnitTestCase { 
    8982                }
    9083        }
    9184
    92         /**
    93          * @expectedDeprecated get_themes
    94          */
    9585        function test_get_themes_contents() {
    96                 $themes = get_themes();
     86                $themes = wp_get_themes();
    9787                // Generic tests that should hold true for any theme
    9888                foreach ( $themes as $k => $theme ) {
    9989                        // Don't run these checks for custom themes.
    10090                        if ( empty( $theme['Author'] ) || false === strpos( $theme['Author'], 'WordPress' ) ) {
    10191                                continue;
    10292                        }
    103 
    104                         $this->assertEquals( $theme['Name'], $k );
     93                        $this->assertEquals( $theme->get_template(), $k );
    10594                        $this->assertNotEmpty( $theme['Title'] );
    10695
    10796                        // important attributes should all be set
    class Tests_Theme extends WP_UnitTestCase { 
    222211                return array( 'License' );
    223212        }
    224213
    225         /**
    226          * @expectedDeprecated get_themes
    227          * @expectedDeprecated get_current_theme
    228          */
    229214        function test_switch_theme() {
    230                 $themes = get_themes();
     215                $themes = wp_get_themes();
    231216
    232217                // Switch to each theme in sequence.
    233218                // Do it twice to make sure we switch to the first theme, even if it's our starting theme.
    class Tests_Theme extends WP_UnitTestCase { 
    241226                                else
    242227                                        switch_theme( $theme['Stylesheet'] );
    243228
    244                                 $this->assertEquals($name, get_current_theme());
     229                                $this->assertEquals($name, wp_get_theme()->get_template() );
    245230
    246231                                // make sure the various get_* functions return the correct values
    247232                                $this->assertEquals($theme['Template'], get_template());