WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (2 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/WPTheme.php

    r41601 r42343  
    88        $this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
    99
    10         $this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
     10        $this->orig_theme_dir            = $GLOBALS['wp_theme_directories'];
    1111        $GLOBALS['wp_theme_directories'] = array( $this->theme_root );
    1212
    13         add_filter('theme_root', array($this, '_theme_root'));
    14         add_filter( 'stylesheet_root', array($this, '_theme_root') );
    15         add_filter( 'template_root', array($this, '_theme_root') );
     13        add_filter( 'theme_root', array( $this, '_theme_root' ) );
     14        add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
     15        add_filter( 'template_root', array( $this, '_theme_root' ) );
    1616        // clear caches
    1717        wp_clean_themes_cache();
     
    2121    function tearDown() {
    2222        $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
    23         remove_filter('theme_root', array($this, '_theme_root'));
    24         remove_filter( 'stylesheet_root', array($this, '_theme_root') );
    25         remove_filter( 'template_root', array($this, '_theme_root') );
     23        remove_filter( 'theme_root', array( $this, '_theme_root' ) );
     24        remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
     25        remove_filter( 'template_root', array( $this, '_theme_root' ) );
    2626        wp_clean_themes_cache();
    2727        unset( $GLOBALS['wp_themes'] );
     
    3030
    3131    // replace the normal theme root dir with our premade test dir
    32     function _theme_root($dir) {
     32    function _theme_root( $dir ) {
    3333        return $this->theme_root;
    3434    }
     
    3737
    3838        //Meta
    39         $this->assertEquals( 'My Theme', $theme->get('Name') );
    40         $this->assertEquals( 'http://example.org/',$theme->get('ThemeURI') );
    41         $this->assertEquals( 'An example theme', $theme->get('Description') );
    42         $this->assertEquals( 'Minnie Bannister', $theme->get('Author') );
    43         $this->assertEquals( 'http://example.com/', $theme->get('AuthorURI') );
    44         $this->assertEquals( '1.3', $theme->get('Version') );
    45         $this->assertEquals( '', $theme->get('Template') );
    46         $this->assertEquals( 'publish', $theme->get('Status') );
    47         $this->assertEquals( array(), $theme->get('Tags') );
     39        $this->assertEquals( 'My Theme', $theme->get( 'Name' ) );
     40        $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) );
     41        $this->assertEquals( 'An example theme', $theme->get( 'Description' ) );
     42        $this->assertEquals( 'Minnie Bannister', $theme->get( 'Author' ) );
     43        $this->assertEquals( 'http://example.com/', $theme->get( 'AuthorURI' ) );
     44        $this->assertEquals( '1.3', $theme->get( 'Version' ) );
     45        $this->assertEquals( '', $theme->get( 'Template' ) );
     46        $this->assertEquals( 'publish', $theme->get( 'Status' ) );
     47        $this->assertEquals( array(), $theme->get( 'Tags' ) );
    4848
    4949        //Important
     
    5656
    5757        //Meta
    58         $this->assertEquals( 'My Subdir Theme', $theme->get('Name') );
    59         $this->assertEquals( 'http://example.org/',$theme->get('ThemeURI') );
    60         $this->assertEquals( 'An example theme in a sub directory', $theme->get('Description') );
    61         $this->assertEquals( 'Mr. WordPress', $theme->get('Author') );
    62         $this->assertEquals( 'http://wordpress.org/', $theme->get('AuthorURI') );
    63         $this->assertEquals( '0.1', $theme->get('Version') );
    64         $this->assertEquals( '', $theme->get('Template') );
    65         $this->assertEquals( 'publish', $theme->get('Status') );
    66         $this->assertEquals( array(), $theme->get('Tags') );
     58        $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) );
     59        $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) );
     60        $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) );
     61        $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) );
     62        $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
     63        $this->assertEquals( '0.1', $theme->get( 'Version' ) );
     64        $this->assertEquals( '', $theme->get( 'Template' ) );
     65        $this->assertEquals( 'publish', $theme->get( 'Status' ) );
     66        $this->assertEquals( array(), $theme->get( 'Tags' ) );
    6767
    6868        //Important
     
    7979
    8080        //Meta
    81         $this->assertEquals( 'My Subdir Theme', $theme->get('Name') );
    82         $this->assertEquals( 'http://example.org/',$theme->get('ThemeURI') );
    83         $this->assertEquals( 'An example theme in a sub directory', $theme->get('Description') );
    84         $this->assertEquals( 'Mr. WordPress', $theme->get('Author') );
    85         $this->assertEquals( 'http://wordpress.org/', $theme->get('AuthorURI') );
    86         $this->assertEquals( '0.1', $theme->get('Version') );
    87         $this->assertEquals( '', $theme->get('Template') );
    88         $this->assertEquals( 'publish', $theme->get('Status') );
    89         $this->assertEquals( array(), $theme->get('Tags') );
     81        $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) );
     82        $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) );
     83        $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) );
     84        $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) );
     85        $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) );
     86        $this->assertEquals( '0.1', $theme->get( 'Version' ) );
     87        $this->assertEquals( '', $theme->get( 'Template' ) );
     88        $this->assertEquals( 'publish', $theme->get( 'Status' ) );
     89        $this->assertEquals( array(), $theme->get( 'Tags' ) );
    9090
    9191        //Important
     
    105105        // Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly.
    106106        $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) );
    107         $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri()   ) );
     107        $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) );
    108108
    109109        // Check that wp_customize_url() uses url encoding, as it is a query arg (spaces become +)
     
    145145     */
    146146    function test_child_theme_with_itself_as_parent_should_appear_as_broken() {
    147         $theme = new WP_Theme( 'child-parent-itself', $this->theme_root );
     147        $theme  = new WP_Theme( 'child-parent-itself', $this->theme_root );
    148148        $errors = $theme->errors();
    149149        $this->assertWPError( $errors );
     
    159159     */
    160160    function test_wp_theme_network_enable_single_theme() {
    161         $theme = 'testtheme-1';
     161        $theme                  = 'testtheme-1';
    162162        $current_allowed_themes = get_site_option( 'allowedthemes' );
    163163        WP_Theme::network_enable_theme( $theme );
     
    176176     */
    177177    function test_wp_theme_network_enable_multiple_themes() {
    178         $themes = array( 'testtheme-2', 'testtheme-3' );
     178        $themes                 = array( 'testtheme-2', 'testtheme-3' );
    179179        $current_allowed_themes = get_site_option( 'allowedthemes' );
    180180        WP_Theme::network_enable_theme( $themes );
    181181        $new_allowed_themes = get_site_option( 'allowedthemes' );
    182182        update_site_option( 'allowedthemes', $current_allowed_themes ); // reset previous value.
    183         $current_allowed_themes = array_merge( $current_allowed_themes, array( 'testtheme-2' => true, 'testtheme-3' => true ) );
     183        $current_allowed_themes = array_merge(
     184            $current_allowed_themes, array(
     185                'testtheme-2' => true,
     186                'testtheme-3' => true,
     187            )
     188        );
    184189
    185190        $this->assertEqualSetsWithIndex( $current_allowed_themes, $new_allowed_themes );
     
    195200        $current_allowed_themes = get_site_option( 'allowedthemes' );
    196201
    197         $allowed_themes = array( 'existing-1' => true, 'existing-2' => true, 'existing-3' => true );
     202        $allowed_themes = array(
     203            'existing-1' => true,
     204            'existing-2' => true,
     205            'existing-3' => true,
     206        );
    198207        update_site_option( 'allowedthemes', $allowed_themes );
    199208
     
    216225        $current_allowed_themes = get_site_option( 'allowedthemes' );
    217226
    218         $allowed_themes = array( 'existing-4' => true, 'existing-5' => true, 'existing-6' => true );
     227        $allowed_themes = array(
     228            'existing-4' => true,
     229            'existing-5' => true,
     230            'existing-6' => true,
     231        );
    219232        update_site_option( 'allowedthemes', $allowed_themes );
    220233
Note: See TracChangeset for help on using the changeset viewer.