Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r46719 r47122  
    9292            $this->assertFalse( $theme->errors() );
    9393            $_theme = wp_get_theme( $theme->get_stylesheet() );
    94             // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded)
     94            // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded).
    9595            $this->assertEquals( $theme->get( 'Name' ), $_theme->get( 'Name' ) );
    9696            $this->assertEquals( $theme, $_theme );
     
    103103    function test_get_themes_contents() {
    104104        $themes = get_themes();
    105         // Generic tests that should hold true for any theme
     105        // Generic tests that should hold true for any theme.
    106106        foreach ( $themes as $k => $theme ) {
    107107            // Don't run these checks for custom themes.
     
    113113            $this->assertNotEmpty( $theme['Title'] );
    114114
    115             // important attributes should all be set
     115            // Important attributes should all be set.
    116116            $default_headers = array(
    117117                'Title'          => 'Theme Title',
     
    126126                'Author'         => 'Author',
    127127                'Tags'           => 'Tags',
    128                 // Introduced in WordPress 2.9
     128                // Introduced in WordPress 2.9.
    129129                'Theme Root'     => 'Theme Root',
    130130                'Theme Root URI' => 'Theme Root URI',
     
    134134            }
    135135
    136             // Make the tests work both for WordPress 2.8.5 and WordPress 2.9-rare
     136            // Make the tests work both for WordPress 2.8.5 and WordPress 2.9-rare.
    137137            $dir = isset( $theme['Theme Root'] ) ? '' : WP_CONTENT_DIR;
    138138
    139             // important attributes should all not be empty as well
     139            // Important attributes should all not be empty as well.
    140140            $this->assertNotEmpty( $theme['Description'] );
    141141            $this->assertNotEmpty( $theme['Author'] );
     
    144144            $this->assertNotEmpty( $theme['Stylesheet'] );
    145145
    146             // template files should all exist
     146            // Template files should all exist.
    147147            $this->assertTrue( is_array( $theme['Template Files'] ) );
    148148            $this->assertTrue( count( $theme['Template Files'] ) > 0 );
     
    152152            }
    153153
    154             // css files should all exist
     154            // CSS files should all exist.
    155155            $this->assertTrue( is_array( $theme['Stylesheet Files'] ) );
    156156            $this->assertTrue( count( $theme['Stylesheet Files'] ) > 0 );
     
    271271        for ( $i = 0; $i < 3; $i++ ) {
    272272            foreach ( $themes as $name => $theme ) {
    273                 // switch to this theme
     273                // Switch to this theme.
    274274                if ( 2 === $i ) {
    275275                    switch_theme( $theme['Template'], $theme['Stylesheet'] );
     
    280280                $this->assertEquals( $name, get_current_theme() );
    281281
    282                 // make sure the various get_* functions return the correct values
     282                // Make sure the various get_* functions return the correct values.
    283283                $this->assertEquals( $theme['Template'], get_template() );
    284284                $this->assertEquals( $theme['Stylesheet'], get_stylesheet() );
     
    293293                $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() );
    294294                $this->assertEquals( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() );
    295                 #               $this->assertEquals($root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri());
     295                // $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() );
    296296
    297297                $this->assertEquals( $root_fs . '/' . get_template(), get_template_directory() );
    298298                $this->assertEquals( $root_uri . '/' . get_template(), get_template_directory_uri() );
    299299
    300                 //get_query_template
    301 
    302                 // template file that doesn't exist
     300                // get_query_template()
     301
     302                // Template file that doesn't exist.
    303303                $this->assertEquals( '', get_query_template( rand_str() ) );
    304304
    305                 // template files that do exist
    306                 //foreach ($theme['Template Files'] as $path) {
    307                 //$file = basename($path, '.php');
    308                 // FIXME: untestable because get_query_template uses TEMPLATEPATH
    309                 //$this->assertEquals('', get_query_template($file));
    310                 //}
    311 
    312                 // these are kind of tautologies but at least exercise the code
     305                // Template files that do exist.
     306                /*
     307                foreach ( $theme['Template Files'] as $path ) {
     308                    $file = basename($path, '.php');
     309                    FIXME: untestable because get_query_template() uses TEMPLATEPATH.
     310                    $this->assertEquals('', get_query_template($file));
     311                }
     312                */
     313
     314                // These are kind of tautologies but at least exercise the code.
    313315                $this->assertEquals( get_404_template(), get_query_template( '404' ) );
    314316                $this->assertEquals( get_archive_template(), get_query_template( 'archive' ) );
     
    325327                $this->assertEquals( get_tag_template(), get_query_template( 'tag' ) );
    326328
    327                 // nb: this probably doesn't run because WP_INSTALLING is defined
     329                // nb: This probably doesn't run because WP_INSTALLING is defined.
    328330                $this->assertTrue( validate_current_theme() );
    329331            }
     
    332334
    333335    function test_switch_theme_bogus() {
    334         // try switching to a theme that doesn't exist
     336        // Try switching to a theme that doesn't exist.
    335337        $template = rand_str();
    336338        $style    = rand_str();
     
    343345        $this->assertFalse( $theme->exists() );
    344346
    345         // these return the bogus name - perhaps not ideal behaviour?
     347        // These return the bogus name - perhaps not ideal behaviour?
    346348        $this->assertEquals( $template, get_template() );
    347349        $this->assertEquals( $style, get_stylesheet() );
     
    371373        do_action( 'customize_register', $wp_customize );
    372374
    373         // The post_date for auto-drafts is bumped to match the changeset post_date whenever it is modified to keep them from from being garbage collected by wp_delete_auto_drafts().
     375        // The post_date for auto-drafts is bumped to match the changeset post_date whenever it is modified
     376        // to keep them from from being garbage collected by wp_delete_auto_drafts().
    374377        $wp_customize->save_changeset_post(
    375378            array(
Note: See TracChangeset for help on using the changeset viewer.