Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 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/category.php

    r46586 r47122  
    2121     */
    2222    function test_get_all_category_ids() {
    23         // create categories
     23        // Ccreate categories.
    2424        self::factory()->category->create_many( 2 );
    2525
    26         // create new taxonomy to ensure not included
     26        // Create new taxonomy to ensure not included.
    2727        register_taxonomy( 'test_tax_cat', 'post' );
    2828        wp_insert_term( 'test1', 'test_tax_cat' );
    2929
    30         // Validate length is 1 + created due to uncategorized
     30        // Validate length is 1 + created due to uncategorized.
    3131        $cat_ids = get_all_category_ids();
    3232        $this->assertEquals( 3, count( $cat_ids ) );
     
    3838    function test_get_category_by_slug() {
    3939
    40         // create Test Categories
     40        // Create test categories.
    4141        $testcat  = self::factory()->category->create_and_get(
    4242            array(
     
    5252        );
    5353
    54         // validate category is returned by slug
     54        // Validate category is returned by slug.
    5555        $ret_testcat = get_category_by_slug( 'testcat' );
    5656        $this->assertEquals( $testcat->term_id, $ret_testcat->term_id );
     
    5858        $this->assertEquals( $testcat->term_id, $ret_testcat->term_id );
    5959
    60         // validate unknown category returns false
     60        // Validate unknown category returns false.
    6161        $this->assertFalse( get_category_by_slug( 'testcat3' ) );
    6262
     
    6868    function test__make_cat_compat() {
    6969
    70         // create Test Categories and Array Representations
     70        // Create test categories and array representations.
    7171        $testcat_array            = array(
    7272            'slug'        => 'testmcc',
     
    8686        $testcat2_array['term_id'] = $testcat2->term_id;
    8787
    88         // unset properties to enable validation of object
     88        // Unset properties to enable validation of object.
    8989        unset( $testcat->cat_ID );
    9090        unset( $testcat->category_count );
     
    101101        unset( $testcat2->category_parent );
    102102
    103         // make Compatible
     103        // Make compatible.
    104104        _make_cat_compat( $testcat );
    105105        _make_cat_compat( $testcat2 );
     
    107107        _make_cat_compat( $testcat2_array );
    108108
    109         // Validate Compatibility Object
     109        // Validate compatibility object.
    110110        $this->assertEquals( $testcat->cat_ID, $testcat->term_id );
    111111        $this->assertEquals( $testcat->category_count, $testcat->count );
     
    115115        $this->assertEquals( $testcat->category_parent, $testcat->parent );
    116116
    117         // Validate Compatibility Object with Parent
     117        // Validate compatibility object with parent.
    118118        $this->assertEquals( $testcat->cat_ID, $testcat->term_id );
    119119        $this->assertEquals( $testcat->category_count, $testcat->count );
     
    123123        $this->assertEquals( $testcat->category_parent, $testcat->parent );
    124124
    125         // Validate Compatibility Array
     125        // Validate compatibility array.
    126126        $this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] );
    127127        $this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] );
     
    131131        $this->assertEquals( $testcat_array['category_parent'], $testcat_array['parent'] );
    132132
    133         // Validate Compatibility Array with Parent
     133        // Validate compatibility array with parent.
    134134        $this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] );
    135135        $this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] );
     
    145145    function test_get_cat_name() {
    146146
    147         // create Test Category
     147        // Create test category.
    148148        $testcat = self::factory()->category->create_and_get(
    149149            array(
     
    153153        );
    154154
    155         // Validate
     155        // Validate.
    156156        $this->assertEquals( $testcat->name, get_cat_name( $testcat->term_id ) );
    157157        $this->assertEquals( '', get_cat_name( -1 ) );
     
    165165    function test_get_cat_ID() {
    166166
    167         // create Test Category
     167        // Create test category.
    168168        $testcat = self::factory()->category->create_and_get(
    169169            array(
     
    173173        );
    174174
    175         // Validate
     175        // Validate.
    176176        $this->assertEquals( $testcat->term_id, get_cat_ID( $testcat->name ) );
    177177        $this->assertEquals( 0, get_cat_ID( 'NO CAT' ) );
     
    185185    function test_get_category_by_path() {
    186186
    187         // create Test Categories
     187        // Create test categories.
    188188        $root_id           = self::factory()->category->create(
    189189            array(
     
    199199        $root_cat_cat_id   = self::factory()->category->create(
    200200            array(
    201                 'slug'   => 'cat', //note this is modified on create
     201                'slug'   => 'cat', // Note this is modified on create.
    202202                'parent' => $root_cat_id,
    203203            )
     
    211211        $root_path_cat_id  = self::factory()->category->create(
    212212            array(
    213                 'slug'   => 'cat', //note this is modified on create
     213                'slug'   => 'cat', // Note this is modified on create.
    214214                'parent' => $root_path_id,
    215215            )
     
    223223        $root_level_cat_id = self::factory()->category->create(
    224224            array(
    225                 'slug'   => 'cat', //note this is modified on create
     225                'slug'   => 'cat', // Note this is modified on create.
    226226                'parent' => $root_level_id,
    227227            )
    228228        );
    229229
    230         // Validate Full Match
     230        // Validate full match.
    231231        $ret_cat = get_category_by_path( '/root/level-1', true );
    232232        $this->assertEquals( $root_level_id, $ret_cat->term_id );
     
    234234        $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );
    235235
    236         // Validate Partial Match
     236        // Validate partial match.
    237237        $ret_cat = get_category_by_path( 'level-1', false );
    238238        $this->assertEquals( $root_level_id, $ret_cat->term_id );
Note: See TracChangeset for help on using the changeset viewer.