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/date/query.php

    r46586 r47122  
    322322        $q = new WP_Date_Query( array() );
    323323
    324         // Single integer
     324        // Single integer.
    325325        $found = $q->build_value( 'IN', 4 );
    326326        $this->assertSame( '(4)', $found );
    327327
    328         // Single non-integer
     328        // Single non-integer.
    329329        $found = $q->build_value( 'IN', 'foo' );
    330330        $this->assertFalse( $found );
    331331
    332         // Array of integers
     332        // Array of integers.
    333333        $found = $q->build_value( 'IN', array( 1, 4, 7 ) );
    334334        $this->assertSame( '(1,4,7)', $found );
    335335
    336         // Array containing non-integers
     336        // Array containing non-integers.
    337337        $found = $q->build_value( 'IN', array( 1, 'foo', 7 ) );
    338338        $this->assertSame( '(1,7)', $found );
     
    345345        $q = new WP_Date_Query( array() );
    346346
    347         // Single integer
     347        // Single integer.
    348348        $found = $q->build_value( 'NOT IN', 4 );
    349349        $this->assertSame( '(4)', $found );
    350350
    351         // Single non-integer
     351        // Single non-integer.
    352352        $found = $q->build_value( 'NOT IN', 'foo' );
    353353        $this->assertFalse( $found );
    354354
    355         // Array of integers
     355        // Array of integers.
    356356        $found = $q->build_value( 'NOT IN', array( 1, 4, 7 ) );
    357357        $this->assertSame( '(1,4,7)', $found );
    358358
    359         // Array containing non-integers
     359        // Array containing non-integers.
    360360        $found = $q->build_value( 'NOT IN', array( 1, 'foo', 7 ) );
    361361        $this->assertSame( '(1,7)', $found );
     
    504504        $q = new WP_Date_Query( array() );
    505505
    506         // This might be a fragile test if it takes longer than 1 second to run
     506        // This might be a fragile test if it takes longer than 1 second to run.
    507507        $found    = $q->build_mysql_datetime( 'foo' );
    508508        $expected = gmdate( 'Y-m-d H:i:s', false );
     
    608608        $q = new WP_Date_Query( array() );
    609609
    610         // Just hour
     610        // Just hour.
    611611        $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ) );
    612612        $this->assertSame( 'HOUR( post_date ) IN (1,2)', $found );
    613613
    614         // Skip minute
     614        // Skip minute.
    615615        $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ), null, 6 );
    616616        $this->assertSame( 'HOUR( post_date ) IN (1,2) AND SECOND( post_date ) IN (6)', $found );
    617617
    618         // All three
     618        // All three.
    619619        $found = $q->build_time_query( 'post_date', 'IN', array( 1, 2 ), array( 3, 4, 5 ), 6 );
    620620        $this->assertSame( 'HOUR( post_date ) IN (1,2) AND MINUTE( post_date ) IN (3,4,5) AND SECOND( post_date ) IN (6)', $found );
     
    624624        $q = new WP_Date_Query( array() );
    625625
    626         // Just hour
     626        // Just hour.
    627627        $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ) );
    628628        $this->assertSame( 'HOUR( post_date ) NOT IN (1,2)', $found );
    629629
    630         // Skip minute
     630        // Skip minute.
    631631        $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ), null, 6 );
    632632        $this->assertSame( 'HOUR( post_date ) NOT IN (1,2) AND SECOND( post_date ) NOT IN (6)', $found );
    633633
    634         // All three
     634        // All three.
    635635        $found = $q->build_time_query( 'post_date', 'NOT IN', array( 1, 2 ), array( 3, 4, 5 ), 6 );
    636636        $this->assertSame( 'HOUR( post_date ) NOT IN (1,2) AND MINUTE( post_date ) NOT IN (3,4,5) AND SECOND( post_date ) NOT IN (6)', $found );
     
    640640        $q = new WP_Date_Query( array() );
    641641
    642         // Just hour
     642        // Just hour.
    643643        $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ) );
    644644        $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2', $found );
    645645
    646         // Skip minute
     646        // Skip minute.
    647647        $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ), null, array( 6, 7 ) );
    648648        $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2 AND SECOND( post_date ) BETWEEN 6 AND 7', $found );
    649649
    650         // All three
     650        // All three.
    651651        $found = $q->build_time_query( 'post_date', 'BETWEEN', array( 1, 2 ), array( 3, 4 ), array( 6, 7 ) );
    652652        $this->assertSame( 'HOUR( post_date ) BETWEEN 1 AND 2 AND MINUTE( post_date ) BETWEEN 3 AND 4 AND SECOND( post_date ) BETWEEN 6 AND 7', $found );
     
    656656        $q = new WP_Date_Query( array() );
    657657
    658         // Just hour
     658        // Just hour.
    659659        $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ) );
    660660        $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2', $found );
    661661
    662         // Skip minute
     662        // Skip minute.
    663663        $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ), null, array( 6, 7 ) );
    664664        $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2 AND SECOND( post_date ) NOT BETWEEN 6 AND 7', $found );
    665665
    666         // All three
     666        // All three.
    667667        $found = $q->build_time_query( 'post_date', 'NOT BETWEEN', array( 1, 2 ), array( 3, 4 ), array( 6, 7 ) );
    668668        $this->assertSame( 'HOUR( post_date ) NOT BETWEEN 1 AND 2 AND MINUTE( post_date ) NOT BETWEEN 3 AND 4 AND SECOND( post_date ) NOT BETWEEN 6 AND 7', $found );
     
    704704
    705705        // $compare value is floating point - use regex to account for
    706         // varying precision on different PHP installations
     706        // varying precision on different PHP installations.
    707707        $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) );
    708708    }
     
    715715
    716716        // $compare value is floating point - use regex to account for
    717         // varying precision on different PHP installations
     717        // varying precision on different PHP installations.
    718718        $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) );
    719719    }
     
    726726
    727727        // $compare value is floating point - use regex to account for
    728         // varying precision on different PHP installations
     728        // varying precision on different PHP installations.
    729729        $this->assertRegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) );
    730730    }
Note: See TracChangeset for help on using the changeset viewer.