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.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2019-07-08 00:55:20 +00:00
parent 431bc58a48
commit c6c78490e2
91 changed files with 435 additions and 320 deletions

View File

@@ -22,14 +22,14 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
*
* @var int
*/
protected $slowThreshold;
protected $slow_threshold;
/**
* Number of tests to report on for slowness.
*
* @var int
*/
protected $reportLength;
protected $report_length;
/**
* Collection of slow tests.
@@ -166,11 +166,11 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
* Whether the given test execution time is considered slow.
*
* @param int $time Test execution time in milliseconds
* @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
* @param int $slow_threshold Test execution time at which a test should be considered slow (milliseconds)
* @return bool
*/
protected function isSlow( $time, $slowThreshold ) {
return $time >= $slowThreshold;
protected function isSlow( $time, $slow_threshold ) {
return $time >= $slow_threshold;
}
/**
@@ -220,7 +220,7 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
* @return int
*/
protected function getReportLength() {
return min( count( $this->slow ), $this->reportLength );
return min( count( $this->slow ), $this->report_length );
}
/**
@@ -244,19 +244,19 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
* Renders slow test report header.
*/
protected function renderHeader() {
echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold );
}
/**
* Renders slow test report body.
*/
protected function renderBody() {
$slowTests = $this->slow;
$slow_tests = $this->slow;
$length = $this->getReportLength( $slowTests );
$length = $this->getReportLength( $slow_tests );
for ( $i = 1; $i <= $length; ++$i ) {
$label = key( $slowTests );
$time = array_shift( $slowTests );
$label = key( $slow_tests );
$time = array_shift( $slow_tests );
echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
}
@@ -268,7 +268,7 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
protected function renderFooter() {
$hidden = $this->getHiddenCount( $this->slow );
if ( $hidden ) {
echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
echo sprintf( '...and there %s %s more above your threshold hidden from view', 1 === $hidden ? 'is' : 'are', $hidden );
}
}
@@ -278,8 +278,8 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
* @param array $options
*/
protected function loadOptions( array $options ) {
$this->slowThreshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
$this->reportLength = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
$this->slow_threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
$this->report_length = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
}
/**
@@ -302,6 +302,6 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
protected function getSlowThreshold( PHPUnit_Framework_TestCase $test ) {
$ann = $test->getAnnotations();
return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold;
}
}