WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/08/2019 12:55:20 AM (2 years ago)
Author:
pento
Message:

Coding Standards: Fix the remaining issues in /tests.

All PHP files in /tests now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs phpcs on the /tests directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/speed-trap-listener.php

    r42343 r45607  
    2323     * @var int
    2424     */
    25     protected $slowThreshold;
     25    protected $slow_threshold;
    2626
    2727    /**
     
    3030     * @var int
    3131     */
    32     protected $reportLength;
     32    protected $report_length;
    3333
    3434    /**
     
    167167     *
    168168     * @param int $time          Test execution time in milliseconds
    169      * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
     169     * @param int $slow_threshold Test execution time at which a test should be considered slow (milliseconds)
    170170     * @return bool
    171171     */
    172     protected function isSlow( $time, $slowThreshold ) {
    173         return $time >= $slowThreshold;
     172    protected function isSlow( $time, $slow_threshold ) {
     173        return $time >= $slow_threshold;
    174174    }
    175175
     
    221221     */
    222222    protected function getReportLength() {
    223         return min( count( $this->slow ), $this->reportLength );
     223        return min( count( $this->slow ), $this->report_length );
    224224    }
    225225
     
    245245     */
    246246    protected function renderHeader() {
    247         echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
     247        echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold );
    248248    }
    249249
     
    252252     */
    253253    protected function renderBody() {
    254         $slowTests = $this->slow;
    255 
    256         $length = $this->getReportLength( $slowTests );
     254        $slow_tests = $this->slow;
     255
     256        $length = $this->getReportLength( $slow_tests );
    257257        for ( $i = 1; $i <= $length; ++$i ) {
    258             $label = key( $slowTests );
    259             $time  = array_shift( $slowTests );
     258            $label = key( $slow_tests );
     259            $time  = array_shift( $slow_tests );
    260260
    261261            echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
     
    268268    protected function renderFooter() {
    269269        if ( $hidden = $this->getHiddenCount( $this->slow ) ) {
    270             echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
     270            echo sprintf( '...and there %s %s more above your threshold hidden from view', 1 === $hidden ? 'is' : 'are', $hidden );
    271271        }
    272272    }
     
    278278     */
    279279    protected function loadOptions( array $options ) {
    280         $this->slowThreshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
    281         $this->reportLength  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
     280        $this->slow_threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
     281        $this->report_length  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
    282282    }
    283283
     
    302302        $ann = $test->getAnnotations();
    303303
    304         return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
     304        return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold;
    305305    }
    306306}
Note: See TracChangeset for help on using the changeset viewer.