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/post/meta.php

    r46586 r47122  
    4646
    4747    function test_unique_postmeta() {
    48         // Add a unique post meta item
     48        // Add a unique post meta item.
    4949        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique', 'value', true ) );
    5050
    51         // Check unique is enforced
     51        // Check unique is enforced.
    5252        $this->assertFalse( add_post_meta( self::$post_id, 'unique', 'another value', true ) );
    5353
    54         //Check it exists
     54        // Check it exists.
    5555        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique', true ) );
    5656        $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique', false ) );
    5757
    58         //Fail to delete the wrong value
     58        // Fail to delete the wrong value.
    5959        $this->assertFalse( delete_post_meta( self::$post_id, 'unique', 'wrong value' ) );
    6060
    61         //Delete it
     61        // Delete it.
    6262        $this->assertTrue( delete_post_meta( self::$post_id, 'unique', 'value' ) );
    6363
    64         //Check it is deleted
     64        // Check it is deleted.
    6565        $this->assertEquals( '', get_post_meta( self::$post_id, 'unique', true ) );
    6666        $this->assertEquals( array(), get_post_meta( self::$post_id, 'unique', false ) );
     
    6969
    7070    function test_nonunique_postmeta() {
    71         // Add two non unique post meta item
     71        // Add two non-unique post meta items.
    7272        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'value' ) );
    7373        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'another value' ) );
    7474
    75         //Check they exists
     75        // Check they exist.
    7676        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'nonunique', true ) );
    7777        $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) );
    7878
    79         //Fail to delete the wrong value
     79        // Fail to delete the wrong value.
    8080        $this->assertFalse( delete_post_meta( self::$post_id, 'nonunique', 'wrong value' ) );
    8181
    82         //Delete the first one
     82        // Delete the first one.
    8383        $this->assertTrue( delete_post_meta( self::$post_id, 'nonunique', 'value' ) );
    8484
    85         //Check the remainder exists
     85        // Check the remainder exists.
    8686        $this->assertEquals( 'another value', get_post_meta( self::$post_id, 'nonunique', true ) );
    8787        $this->assertEquals( array( 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) );
    8888
    89         //Add a third one
     89        // Add a third one.
    9090        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'someother value' ) );
    9191
    92         //Check they exists
     92        // Check they exist.
    9393        $expected = array(
    9494            'someother value',
     
    101101        $this->assertEquals( $expected, $actual );
    102102
    103         //Delete the lot
     103        // Delete the lot.
    104104        $this->assertTrue( delete_post_meta_by_key( 'nonunique' ) );
    105105    }
    106106
    107107    function test_update_post_meta() {
    108         // Add a unique post meta item
     108        // Add a unique post meta item.
    109109        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_update', 'value', true ) );
    110110
    111         // Add two non unique post meta item
     111        // Add two non-unique post meta items.
    112112        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique_update', 'value' ) );
    113113        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) );
    114114
    115         //Check they exists
     115        // Check they exist.
    116116        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_update', true ) );
    117117        $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) );
     
    119119        $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) );
    120120
    121         // Update them
     121        // Update them.
    122122        $this->assertTrue( update_post_meta( self::$post_id, 'unique_update', 'new', 'value' ) );
    123123        $this->assertTrue( update_post_meta( self::$post_id, 'nonunique_update', 'new', 'value' ) );
    124124        $this->assertTrue( update_post_meta( self::$post_id, 'nonunique_update', 'another new', 'another value' ) );
    125125
    126         //Check they updated
     126        // Check they updated.
    127127        $this->assertEquals( 'new', get_post_meta( self::$post_id, 'unique_update', true ) );
    128128        $this->assertEquals( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) );
     
    133133
    134134    function test_delete_post_meta() {
    135         // Add a unique post meta item
     135        // Add two unique post meta items.
    136136        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_delete', 'value', true ) );
    137137        $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete', 'value', true ) );
    138138
    139         //Check they exists
     139        // Check they exist.
    140140        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_delete', true ) );
    141141        $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) );
    142142
    143         //Delete one of them
     143        // Delete one of them.
    144144        $this->assertTrue( delete_post_meta( self::$post_id, 'unique_delete', 'value' ) );
    145145
    146         //Check the other still exitsts
     146        // Check the other still exists.
    147147        $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) );
    148148
     
    150150
    151151    function test_delete_post_meta_by_key() {
    152         // Add a unique post meta item
     152        // Add two unique post meta items.
    153153        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_delete_by_key', 'value', true ) );
    154154        $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete_by_key', 'value', true ) );
    155155
    156         //Check they exist
     156        // Check they exist.
    157157        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_delete_by_key', true ) );
    158158        $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) );
    159159
    160         //Delete one of them
     160        // Delete one of them.
    161161        $this->assertTrue( delete_post_meta_by_key( 'unique_delete_by_key' ) );
    162162
    163         //Check the other still exists
     163        // Check the other still exists.
    164164        $this->assertEquals( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) );
    165165        $this->assertEquals( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) );
     
    197197
    198198    function test_update_meta() {
    199         // Add a unique post meta item
     199        // Add a unique post meta item.
    200200        $this->assertInternalType( 'integer', $mid1 = add_post_meta( self::$post_id, 'unique_update', 'value', true ) );
    201201
    202         // Add two non unique post meta item
     202        // Add two non-unique post meta items.
    203203        $this->assertInternalType( 'integer', $mid2 = add_post_meta( self::$post_id, 'nonunique_update', 'value' ) );
    204204        $this->assertInternalType( 'integer', $mid3 = add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) );
    205205
    206         //Check they exist
     206        // Check they exist.
    207207        $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_update', true ) );
    208208        $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) );
     
    210210        $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) );
    211211
    212         // Update them
     212        // Update them.
    213213        $this->assertTrue( update_meta( $mid1, 'unique_update', 'new' ) );
    214214        $this->assertTrue( update_meta( $mid2, 'nonunique_update', 'new' ) );
    215215        $this->assertTrue( update_meta( $mid3, 'nonunique_update', 'another new' ) );
    216216
    217         //Check they updated
     217        // Check they updated.
    218218        $this->assertEquals( 'new', get_post_meta( self::$post_id, 'unique_update', true ) );
    219219        $this->assertEquals( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) );
     
    221221        $this->assertEquals( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) );
    222222
    223         // Slashed update
     223        // Slashed update.
    224224        $data = "'quote and \slash";
    225225        $this->assertTrue( update_meta( $mid1, 'unique_update', addslashes( $data ) ) );
     
    242242        $funky_meta[]    = $classy;
    243243
    244         // Add a post meta item
     244        // Add a post meta item.
    245245        $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'test_funky_post_meta', $funky_meta, true ) );
    246246
    247         //Check they exists
     247        // Check it exists.
    248248        $this->assertEquals( $funky_meta, get_post_meta( self::$post_id, 'test_funky_post_meta', true ) );
    249249
Note: See TracChangeset for help on using the changeset viewer.