GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 699b70...879176 )
by Chris
13:23
created
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/Classes/BraceOnSameLineSniff.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,29 +28,29 @@
 block discarded – undo
28 28
 	/**
29 29
 	 * @inheritDoc
30 30
 	 */
31
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
31
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
32 32
 		$tokens = $phpcsFile->getTokens();
33
-		$errorData = [strtolower($tokens[$stackPtr]['content'])];
33
+		$errorData = [ strtolower( $tokens[ $stackPtr ][ 'content' ] ) ];
34 34
 
35
-		if (isset($tokens[$stackPtr]['scope_opener']) === false) {
35
+		if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === false ) {
36 36
 			return;
37 37
 		}
38 38
 
39
-		$curlyBrace = $tokens[$stackPtr]['scope_opener'];
40
-		$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true);
41
-		$classLine = $tokens[$lastContent]['line'];
42
-		$braceLine = $tokens[$curlyBrace]['line'];
43
-		if ($braceLine !== $classLine) {
44
-			$phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'same line');
39
+		$curlyBrace = $tokens[ $stackPtr ][ 'scope_opener' ];
40
+		$lastContent = $phpcsFile->findPrevious( T_WHITESPACE, ( $curlyBrace - 1 ), $stackPtr, true );
41
+		$classLine = $tokens[ $lastContent ][ 'line' ];
42
+		$braceLine = $tokens[ $curlyBrace ][ 'line' ];
43
+		if ( $braceLine !== $classLine ) {
44
+			$phpcsFile->recordMetric( $stackPtr, 'Class opening brace placement', 'same line' );
45 45
 			$error = 'Opening brace of a %s must be on the same line as the definition';
46 46
 
47
-			$fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNewLine', $errorData);
48
-			if ($fix === true) {
47
+			$fix = $phpcsFile->addFixableError( $error, $curlyBrace, 'OpenBraceNewLine', $errorData );
48
+			if ( $fix === true ) {
49 49
 				$phpcsFile->fixer->beginChangeset();
50
-				$phpcsFile->fixer->replaceToken($lastContent, $tokens[$lastContent]['content'] . ' ');
50
+				$phpcsFile->fixer->replaceToken( $lastContent, $tokens[ $lastContent ][ 'content' ] . ' ' );
51 51
 
52
-				for ($i = $lastContent + 1; $i < $curlyBrace; $i++) {
53
-					$phpcsFile->fixer->replaceToken($i, '');
52
+				for ( $i = $lastContent + 1; $i < $curlyBrace; $i++ ) {
53
+					$phpcsFile->fixer->replaceToken( $i, '' );
54 54
 				}
55 55
 				$phpcsFile->fixer->endChangeset();
56 56
 			}
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/PSR2R/Sniffs/Classes/ClassFileNameSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -53,32 +53,32 @@
 block discarded – undo
53 53
 	 *
54 54
 	 * @return void
55 55
 	 */
56
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
57
-		$fullPath = basename($phpcsFile->getFilename());
58
-		$fileName = substr($fullPath, 0, strrpos($fullPath, '.'));
59
-		if ($fileName === '') {
56
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
57
+		$fullPath = basename( $phpcsFile->getFilename() );
58
+		$fileName = substr( $fullPath, 0, strrpos( $fullPath, '.' ) );
59
+		if ( $fileName === '' ) {
60 60
 			// No filename probably means STDIN, so we can't do this check.
61 61
 			return;
62 62
 		}
63 63
 
64 64
 		$tokens = $phpcsFile->getTokens();
65 65
 
66
-		$previous = $phpcsFile->findPrevious([T_CLASS, T_INTERFACE], $stackPtr - 1);
67
-		if ($previous) {
66
+		$previous = $phpcsFile->findPrevious( [ T_CLASS, T_INTERFACE ], $stackPtr - 1 );
67
+		if ( $previous ) {
68 68
 			// Probably more than a single declaration per file, we only check first one then.
69 69
 			return;
70 70
 		}
71 71
 
72
-		$decName = $phpcsFile->findNext(T_STRING, $stackPtr);
72
+		$decName = $phpcsFile->findNext( T_STRING, $stackPtr );
73 73
 
74
-		if ($tokens[$decName]['content'] !== $fileName) {
74
+		if ( $tokens[ $decName ][ 'content' ] !== $fileName ) {
75 75
 			$error = '%s name doesn\'t match filename; expected "%s %s"';
76 76
 			$data = [
77
-				ucfirst($tokens[$stackPtr]['content']),
78
-				$tokens[$stackPtr]['content'],
77
+				ucfirst( $tokens[ $stackPtr ][ 'content' ] ),
78
+				$tokens[ $stackPtr ][ 'content' ],
79 79
 				$fileName,
80 80
 			];
81
-			$phpcsFile->addError($error, $stackPtr, 'NoMatch', $data);
81
+			$phpcsFile->addError( $error, $stackPtr, 'NoMatch', $data );
82 82
 		}
83 83
 
84 84
 	}
Please login to merge, or discard this patch.
fig-r/psr2r-sniffer/PSR2R/Sniffs/Classes/ClassCreateInstanceSniff.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
 	 * @inheritDoc
12 12
 	 */
13 13
 	public function register() {
14
-		return [T_NEW];
14
+		return [ T_NEW ];
15 15
 	}
16 16
 
17 17
 	/**
18 18
 	 * @inheritDoc
19 19
 	 */
20
-	public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
20
+	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
21 21
 		$tokens = $phpcsFile->getTokens();
22 22
 
23
-		$nextParenthesisIndex = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
23
+		$nextParenthesisIndex = $phpcsFile->findNext( T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true );
24 24
 
25 25
 		// If there is a parenthesis owner then this is not a constructor call
26
-		if ($nextParenthesisIndex && !isset($tokens[$nextParenthesisIndex]['parenthesis_owner'])) {
26
+		if ( $nextParenthesisIndex && ! isset( $tokens[ $nextParenthesisIndex ][ 'parenthesis_owner' ] ) ) {
27 27
 			return;
28 28
 		}
29 29
 
30 30
 		$error = 'Calling class constructors must always include parentheses';
31
-		$constructorIndex = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
31
+		$constructorIndex = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
32 32
 
33 33
 		// We can only invoke the fixer if we know this is a static constructor function call.
34
-		if ($tokens[$constructorIndex]['code'] !== T_STRING && $tokens[$constructorIndex]['code'] !== T_NS_SEPARATOR) {
35
-			$phpcsFile->addError($error, $stackPtr, 'ParenthesisMissing');
34
+		if ( $tokens[ $constructorIndex ][ 'code' ] !== T_STRING && $tokens[ $constructorIndex ][ 'code' ] !== T_NS_SEPARATOR ) {
35
+			$phpcsFile->addError( $error, $stackPtr, 'ParenthesisMissing' );
36 36
 			return;
37 37
 		}
38 38
 
39 39
 		// Scan to the end of possible string\namespace parts.
40 40
 		$nextConstructorPart = $constructorIndex;
41
-		while (true) {
41
+		while ( true ) {
42 42
 			$nextConstructorPart = $phpcsFile->findNext(
43 43
 				PHP_CodeSniffer_Tokens::$emptyTokens,
44
-				($nextConstructorPart + 1),
44
+				( $nextConstructorPart + 1 ),
45 45
 				null,
46 46
 				true,
47 47
 				null,
48 48
 				true
49 49
 			);
50
-			if ($nextConstructorPart === false
51
-				|| ($tokens[$nextConstructorPart]['code'] !== T_STRING && $tokens[$nextConstructorPart]['code'] !== T_NS_SEPARATOR)
50
+			if ( $nextConstructorPart === false
51
+				|| ( $tokens[ $nextConstructorPart ][ 'code' ] !== T_STRING && $tokens[ $nextConstructorPart ][ 'code' ] !== T_NS_SEPARATOR )
52 52
 			) {
53 53
 				break;
54 54
 			}
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$constructorIndex = $nextConstructorPart;
57 57
 		}
58 58
 
59
-		$fix = $phpcsFile->addFixableError($error, $constructorIndex, 'ParenthesisMissing');
60
-		if ($fix) {
61
-			$phpcsFile->fixer->addContent($constructorIndex, '()');
59
+		$fix = $phpcsFile->addFixableError( $error, $constructorIndex, 'ParenthesisMissing' );
60
+		if ( $fix ) {
61
+			$phpcsFile->fixer->addContent( $constructorIndex, '()' );
62 62
 		}
63 63
 	}
64 64
 
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/bin/sniff.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 	__DIR__ . '/../vendor/autoload.php',
11 11
 	__DIR__ . '/vendor/autoload.php'
12 12
 ];
13
-foreach ($options as $file) {
14
-	if (file_exists($file)) {
15
-		define('SNIFFER_COMPOSER_INSTALL', $file);
13
+foreach ( $options as $file ) {
14
+	if ( file_exists( $file ) ) {
15
+		define( 'SNIFFER_COMPOSER_INSTALL', $file );
16 16
 		break;
17 17
 	}
18 18
 }
19 19
 require SNIFFER_COMPOSER_INSTALL;
20 20
 
21
-$sniffer = new \PSR2R\Tools\Sniffer($argv);
21
+$sniffer = new \PSR2R\Tools\Sniffer( $argv );
22 22
 
23 23
 $sniffer->sniff();
24 24
 echo 0;
Please login to merge, or discard this patch.
vendor/fig-r/psr2r-sniffer/bin/tokenize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 	__DIR__ . '/../vendor/autoload.php',
11 11
 	__DIR__ . '/vendor/autoload.php'
12 12
 ];
13
-foreach ($options as $file) {
14
-	if (file_exists($file)) {
15
-		define('SNIFFER_COMPOSER_INSTALL', $file);
13
+foreach ( $options as $file ) {
14
+	if ( file_exists( $file ) ) {
15
+		define( 'SNIFFER_COMPOSER_INSTALL', $file );
16 16
 		break;
17 17
 	}
18 18
 }
19 19
 require SNIFFER_COMPOSER_INSTALL;
20 20
 
21
-$tokenizer = new \PSR2R\Tools\Tokenizer($argv);
21
+$tokenizer = new \PSR2R\Tools\Tokenizer( $argv );
22 22
 
23 23
 $tokenizer->tokenize();
24 24
 echo 0;
Please login to merge, or discard this patch.
vendor/extended-cpts/tests/phpunit/includes/SpeedTrapListener.php 3 patches
Indentation   +317 added lines, -317 removed lines patch added patch discarded remove patch
@@ -8,321 +8,321 @@
 block discarded – undo
8 8
  */
9 9
 class SpeedTrapListener implements PHPUnit_Framework_TestListener
10 10
 {
11
-    /**
12
-     * Internal tracking for test suites.
13
-     *
14
-     * Increments as more suites are run, then decremented as they finish. All
15
-     * suites have been run when returns to 0.
16
-     *
17
-     * @var integer
18
-     */
19
-    protected $suites = 0;
20
-
21
-    /**
22
-     * Time in milliseconds at which a test will be considered "slow" and be
23
-     * reported by this listener.
24
-     *
25
-     * @var int
26
-     */
27
-    protected $slowThreshold;
28
-
29
-    /**
30
-     * Number of tests to report on for slowness.
31
-     *
32
-     * @var int
33
-     */
34
-    protected $reportLength;
35
-
36
-    /**
37
-     * Collection of slow tests.
38
-     *
39
-     * @var array
40
-     */
41
-    protected $slow = array();
42
-
43
-    /**
44
-     * Construct a new instance.
45
-     *
46
-     * @param array $options
47
-     */
48
-    public function __construct(array $options = array())
49
-    {
50
-        $this->loadOptions($options);
51
-    }
52
-
53
-    /**
54
-     * An error occurred.
55
-     *
56
-     * @param PHPUnit_Framework_Test $test
57
-     * @param Exception              $e
58
-     * @param float                  $time
59
-     */
60
-    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
61
-    {
62
-    }
63
-
64
-    /**
65
-     * A warning occurred.
66
-     *
67
-     * @param PHPUnit_Framework_Test    $test
68
-     * @param PHPUnit_Framework_Warning $e
69
-     * @param float                     $time
70
-     * @since Method available since Release 5.1.0
71
-     */
72
-    public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time)
73
-    {
74
-    }
75
-
76
-    /**
77
-     * A failure occurred.
78
-     *
79
-     * @param PHPUnit_Framework_Test                 $test
80
-     * @param PHPUnit_Framework_AssertionFailedError $e
81
-     * @param float                                  $time
82
-     */
83
-    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
84
-    {
85
-    }
86
-
87
-    /**
88
-     * Incomplete test.
89
-     *
90
-     * @param PHPUnit_Framework_Test $test
91
-     * @param Exception              $e
92
-     * @param float                  $time
93
-     */
94
-    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
95
-    {
96
-    }
97
-
98
-    /**
99
-     * Risky test.
100
-     *
101
-     * @param PHPUnit_Framework_Test $test
102
-     * @param Exception              $e
103
-     * @param float                  $time
104
-     * @since Method available since Release 4.0.0
105
-     */
106
-    public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
107
-    {
108
-    }
109
-
110
-    /**
111
-     * Skipped test.
112
-     *
113
-     * @param PHPUnit_Framework_Test $test
114
-     * @param Exception              $e
115
-     * @param float                  $time
116
-     */
117
-    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
118
-    {
119
-    }
120
-
121
-    /**
122
-     * A test started.
123
-     *
124
-     * @param PHPUnit_Framework_Test $test
125
-     */
126
-    public function startTest(PHPUnit_Framework_Test $test)
127
-    {
128
-    }
129
-
130
-    /**
131
-     * A test ended.
132
-     *
133
-     * @param PHPUnit_Framework_Test $test
134
-     * @param float                  $time
135
-     */
136
-    public function endTest(PHPUnit_Framework_Test $test, $time)
137
-    {
138
-        if (!$test instanceof PHPUnit_Framework_TestCase) return;
139
-
140
-        $time = $this->toMilliseconds($time);
141
-        $threshold = $this->getSlowThreshold($test);
142
-
143
-        if ($this->isSlow($time, $threshold)) {
144
-            $this->addSlowTest($test, $time);
145
-        }
146
-    }
147
-
148
-    /**
149
-     * A test suite started.
150
-     *
151
-     * @param PHPUnit_Framework_TestSuite $suite
152
-     */
153
-    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
154
-    {
155
-        $this->suites++;
156
-    }
157
-
158
-    /**
159
-     * A test suite ended.
160
-     *
161
-     * @param PHPUnit_Framework_TestSuite $suite
162
-     */
163
-    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
164
-    {
165
-        $this->suites--;
166
-
167
-        if (0 === $this->suites && $this->hasSlowTests()) {
168
-            arsort($this->slow); // Sort longest running tests to the top
169
-
170
-            $this->renderHeader();
171
-            $this->renderBody();
172
-            $this->renderFooter();
173
-        }
174
-    }
175
-
176
-    /**
177
-     * Whether the given test execution time is considered slow.
178
-     *
179
-     * @param int $time          Test execution time in milliseconds
180
-     * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
181
-     * @return bool
182
-     */
183
-    protected function isSlow($time, $slowThreshold)
184
-    {
185
-        return $time >= $slowThreshold;
186
-    }
187
-
188
-    /**
189
-     * Stores a test as slow.
190
-     *
191
-     * @param PHPUnit_Framework_TestCase $test
192
-     * @param int                        $time Test execution time in milliseconds
193
-     */
194
-    protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time)
195
-    {
196
-        $label = $this->makeLabel($test);
197
-
198
-        $this->slow[$label] = $time;
199
-    }
200
-
201
-    /**
202
-     * Whether at least one test has been considered slow.
203
-     *
204
-     * @return bool
205
-     */
206
-    protected function hasSlowTests()
207
-    {
208
-        return !empty($this->slow);
209
-    }
210
-
211
-    /**
212
-     * Convert PHPUnit's reported test time (microseconds) to milliseconds.
213
-     *
214
-     * @param float $time
215
-     * @return int
216
-     */
217
-    protected function toMilliseconds($time)
218
-    {
219
-        return (int) round($time * 1000);
220
-    }
221
-
222
-    /**
223
-     * Label for describing a test.
224
-     *
225
-     * @param PHPUnit_Framework_TestCase $test
226
-     * @return string
227
-     */
228
-    protected function makeLabel(PHPUnit_Framework_TestCase $test)
229
-    {
230
-        return sprintf('%s:%s', get_class($test), $test->getName());
231
-    }
232
-
233
-    /**
234
-     * Calculate number of slow tests to report about.
235
-     *
236
-     * @return int
237
-     */
238
-    protected function getReportLength()
239
-    {
240
-        return min(count($this->slow), $this->reportLength);
241
-    }
242
-
243
-    /**
244
-     * Find how many slow tests occurred that won't be shown due to list length.
245
-     *
246
-     * @return int Number of hidden slow tests
247
-     */
248
-    protected function getHiddenCount()
249
-    {
250
-        $total = count($this->slow);
251
-        $showing = $this->getReportLength($this->slow);
252
-
253
-        $hidden = 0;
254
-        if ($total > $showing) {
255
-            $hidden = $total - $showing;
256
-        }
257
-
258
-        return $hidden;
259
-    }
260
-
261
-    /**
262
-     * Renders slow test report header.
263
-     */
264
-    protected function renderHeader()
265
-    {
266
-        echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold);
267
-    }
268
-
269
-    /**
270
-     * Renders slow test report body.
271
-     */
272
-    protected function renderBody()
273
-    {
274
-        $slowTests = $this->slow;
275
-
276
-        $length = $this->getReportLength($slowTests);
277
-        for ($i = 1; $i <= $length; ++$i) {
278
-            $label = key($slowTests);
279
-            $time = array_shift($slowTests);
280
-
281
-            echo sprintf(" %s. %sms to run %s\n", $i, $time, $label);
282
-        }
283
-    }
284
-
285
-    /**
286
-     * Renders slow test report footer.
287
-     */
288
-    protected function renderFooter()
289
-    {
290
-        if ($hidden = $this->getHiddenCount($this->slow)) {
291
-            echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden);
292
-        }
293
-    }
294
-
295
-    /**
296
-     * Populate options into class internals.
297
-     *
298
-     * @param array $options
299
-     */
300
-    protected function loadOptions(array $options)
301
-    {
302
-        $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500;
303
-        $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10;
304
-    }
305
-
306
-    /**
307
-     * Get slow test threshold for given test. A TestCase can override the
308
-     * suite-wide slow threshold by using the annotation @slowThreshold with
309
-     * the threshold value in milliseconds.
310
-     *
311
-     * The following test will only be considered slow when its execution time
312
-     * reaches 5000ms (5 seconds):
313
-     *
314
-     * <code>
315
-     * @slowThreshold 5000
316
-     * public function testLongRunningProcess() {}
317
-     * </code>
318
-     *
319
-     * @param PHPUnit_Framework_TestCase $test
320
-     * @return int
321
-     */
322
-    protected function getSlowThreshold(PHPUnit_Framework_TestCase $test)
323
-    {
324
-        $ann = $test->getAnnotations();
325
-
326
-        return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
327
-    }
11
+	 /**
12
+	  * Internal tracking for test suites.
13
+	  *
14
+	  * Increments as more suites are run, then decremented as they finish. All
15
+	  * suites have been run when returns to 0.
16
+	  *
17
+	  * @var integer
18
+	  */
19
+	 protected $suites = 0;
20
+
21
+	 /**
22
+	  * Time in milliseconds at which a test will be considered "slow" and be
23
+	  * reported by this listener.
24
+	  *
25
+	  * @var int
26
+	  */
27
+	 protected $slowThreshold;
28
+
29
+	 /**
30
+	  * Number of tests to report on for slowness.
31
+	  *
32
+	  * @var int
33
+	  */
34
+	 protected $reportLength;
35
+
36
+	 /**
37
+	  * Collection of slow tests.
38
+	  *
39
+	  * @var array
40
+	  */
41
+	 protected $slow = array();
42
+
43
+	 /**
44
+	  * Construct a new instance.
45
+	  *
46
+	  * @param array $options
47
+	  */
48
+	 public function __construct(array $options = array())
49
+	 {
50
+		  $this->loadOptions($options);
51
+	 }
52
+
53
+	 /**
54
+	  * An error occurred.
55
+	  *
56
+	  * @param PHPUnit_Framework_Test $test
57
+	  * @param Exception              $e
58
+	  * @param float                  $time
59
+	  */
60
+	 public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
61
+	 {
62
+	 }
63
+
64
+	 /**
65
+	  * A warning occurred.
66
+	  *
67
+	  * @param PHPUnit_Framework_Test    $test
68
+	  * @param PHPUnit_Framework_Warning $e
69
+	  * @param float                     $time
70
+	  * @since Method available since Release 5.1.0
71
+	  */
72
+	 public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time)
73
+	 {
74
+	 }
75
+
76
+	 /**
77
+	  * A failure occurred.
78
+	  *
79
+	  * @param PHPUnit_Framework_Test                 $test
80
+	  * @param PHPUnit_Framework_AssertionFailedError $e
81
+	  * @param float                                  $time
82
+	  */
83
+	 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
84
+	 {
85
+	 }
86
+
87
+	 /**
88
+	  * Incomplete test.
89
+	  *
90
+	  * @param PHPUnit_Framework_Test $test
91
+	  * @param Exception              $e
92
+	  * @param float                  $time
93
+	  */
94
+	 public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
95
+	 {
96
+	 }
97
+
98
+	 /**
99
+	  * Risky test.
100
+	  *
101
+	  * @param PHPUnit_Framework_Test $test
102
+	  * @param Exception              $e
103
+	  * @param float                  $time
104
+	  * @since Method available since Release 4.0.0
105
+	  */
106
+	 public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
107
+	 {
108
+	 }
109
+
110
+	 /**
111
+	  * Skipped test.
112
+	  *
113
+	  * @param PHPUnit_Framework_Test $test
114
+	  * @param Exception              $e
115
+	  * @param float                  $time
116
+	  */
117
+	 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
118
+	 {
119
+	 }
120
+
121
+	 /**
122
+	  * A test started.
123
+	  *
124
+	  * @param PHPUnit_Framework_Test $test
125
+	  */
126
+	 public function startTest(PHPUnit_Framework_Test $test)
127
+	 {
128
+	 }
129
+
130
+	 /**
131
+	  * A test ended.
132
+	  *
133
+	  * @param PHPUnit_Framework_Test $test
134
+	  * @param float                  $time
135
+	  */
136
+	 public function endTest(PHPUnit_Framework_Test $test, $time)
137
+	 {
138
+		  if (!$test instanceof PHPUnit_Framework_TestCase) return;
139
+
140
+		  $time = $this->toMilliseconds($time);
141
+		  $threshold = $this->getSlowThreshold($test);
142
+
143
+		  if ($this->isSlow($time, $threshold)) {
144
+				$this->addSlowTest($test, $time);
145
+		  }
146
+	 }
147
+
148
+	 /**
149
+	  * A test suite started.
150
+	  *
151
+	  * @param PHPUnit_Framework_TestSuite $suite
152
+	  */
153
+	 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
154
+	 {
155
+		  $this->suites++;
156
+	 }
157
+
158
+	 /**
159
+	  * A test suite ended.
160
+	  *
161
+	  * @param PHPUnit_Framework_TestSuite $suite
162
+	  */
163
+	 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
164
+	 {
165
+		  $this->suites--;
166
+
167
+		  if (0 === $this->suites && $this->hasSlowTests()) {
168
+				arsort($this->slow); // Sort longest running tests to the top
169
+
170
+				$this->renderHeader();
171
+				$this->renderBody();
172
+				$this->renderFooter();
173
+		  }
174
+	 }
175
+
176
+	 /**
177
+	  * Whether the given test execution time is considered slow.
178
+	  *
179
+	  * @param int $time          Test execution time in milliseconds
180
+	  * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
181
+	  * @return bool
182
+	  */
183
+	 protected function isSlow($time, $slowThreshold)
184
+	 {
185
+		  return $time >= $slowThreshold;
186
+	 }
187
+
188
+	 /**
189
+	  * Stores a test as slow.
190
+	  *
191
+	  * @param PHPUnit_Framework_TestCase $test
192
+	  * @param int                        $time Test execution time in milliseconds
193
+	  */
194
+	 protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time)
195
+	 {
196
+		  $label = $this->makeLabel($test);
197
+
198
+		  $this->slow[$label] = $time;
199
+	 }
200
+
201
+	 /**
202
+	  * Whether at least one test has been considered slow.
203
+	  *
204
+	  * @return bool
205
+	  */
206
+	 protected function hasSlowTests()
207
+	 {
208
+		  return !empty($this->slow);
209
+	 }
210
+
211
+	 /**
212
+	  * Convert PHPUnit's reported test time (microseconds) to milliseconds.
213
+	  *
214
+	  * @param float $time
215
+	  * @return int
216
+	  */
217
+	 protected function toMilliseconds($time)
218
+	 {
219
+		  return (int) round($time * 1000);
220
+	 }
221
+
222
+	 /**
223
+	  * Label for describing a test.
224
+	  *
225
+	  * @param PHPUnit_Framework_TestCase $test
226
+	  * @return string
227
+	  */
228
+	 protected function makeLabel(PHPUnit_Framework_TestCase $test)
229
+	 {
230
+		  return sprintf('%s:%s', get_class($test), $test->getName());
231
+	 }
232
+
233
+	 /**
234
+	  * Calculate number of slow tests to report about.
235
+	  *
236
+	  * @return int
237
+	  */
238
+	 protected function getReportLength()
239
+	 {
240
+		  return min(count($this->slow), $this->reportLength);
241
+	 }
242
+
243
+	 /**
244
+	  * Find how many slow tests occurred that won't be shown due to list length.
245
+	  *
246
+	  * @return int Number of hidden slow tests
247
+	  */
248
+	 protected function getHiddenCount()
249
+	 {
250
+		  $total = count($this->slow);
251
+		  $showing = $this->getReportLength($this->slow);
252
+
253
+		  $hidden = 0;
254
+		  if ($total > $showing) {
255
+				$hidden = $total - $showing;
256
+		  }
257
+
258
+		  return $hidden;
259
+	 }
260
+
261
+	 /**
262
+	  * Renders slow test report header.
263
+	  */
264
+	 protected function renderHeader()
265
+	 {
266
+		  echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold);
267
+	 }
268
+
269
+	 /**
270
+	  * Renders slow test report body.
271
+	  */
272
+	 protected function renderBody()
273
+	 {
274
+		  $slowTests = $this->slow;
275
+
276
+		  $length = $this->getReportLength($slowTests);
277
+		  for ($i = 1; $i <= $length; ++$i) {
278
+				$label = key($slowTests);
279
+				$time = array_shift($slowTests);
280
+
281
+				echo sprintf(" %s. %sms to run %s\n", $i, $time, $label);
282
+		  }
283
+	 }
284
+
285
+	 /**
286
+	  * Renders slow test report footer.
287
+	  */
288
+	 protected function renderFooter()
289
+	 {
290
+		  if ($hidden = $this->getHiddenCount($this->slow)) {
291
+				echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden);
292
+		  }
293
+	 }
294
+
295
+	 /**
296
+	  * Populate options into class internals.
297
+	  *
298
+	  * @param array $options
299
+	  */
300
+	 protected function loadOptions(array $options)
301
+	 {
302
+		  $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500;
303
+		  $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10;
304
+	 }
305
+
306
+	 /**
307
+	  * Get slow test threshold for given test. A TestCase can override the
308
+	  * suite-wide slow threshold by using the annotation @slowThreshold with
309
+	  * the threshold value in milliseconds.
310
+	  *
311
+	  * The following test will only be considered slow when its execution time
312
+	  * reaches 5000ms (5 seconds):
313
+	  *
314
+	  * <code>
315
+	  * @slowThreshold 5000
316
+	  * public function testLongRunningProcess() {}
317
+	  * </code>
318
+	  *
319
+	  * @param PHPUnit_Framework_TestCase $test
320
+	  * @return int
321
+	  */
322
+	 protected function getSlowThreshold(PHPUnit_Framework_TestCase $test)
323
+	 {
324
+		  $ann = $test->getAnnotations();
325
+
326
+		  return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
327
+	 }
328 328
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @param array $options
47 47
      */
48
-    public function __construct(array $options = array())
48
+    public function __construct( array $options = array() )
49 49
     {
50
-        $this->loadOptions($options);
50
+        $this->loadOptions( $options );
51 51
     }
52 52
 
53 53
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param Exception              $e
58 58
      * @param float                  $time
59 59
      */
60
-    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
60
+    public function addError( PHPUnit_Framework_Test $test, Exception $e, $time )
61 61
     {
62 62
     }
63 63
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param float                     $time
70 70
      * @since Method available since Release 5.1.0
71 71
      */
72
-    public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time)
72
+    public function addWarning( PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time )
73 73
     {
74 74
     }
75 75
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * @param PHPUnit_Framework_AssertionFailedError $e
81 81
      * @param float                                  $time
82 82
      */
83
-    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
83
+    public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time )
84 84
     {
85 85
     }
86 86
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param Exception              $e
92 92
      * @param float                  $time
93 93
      */
94
-    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
94
+    public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time )
95 95
     {
96 96
     }
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      * @param float                  $time
104 104
      * @since Method available since Release 4.0.0
105 105
      */
106
-    public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
106
+    public function addRiskyTest( PHPUnit_Framework_Test $test, Exception $e, $time )
107 107
     {
108 108
     }
109 109
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param Exception              $e
115 115
      * @param float                  $time
116 116
      */
117
-    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
117
+    public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time )
118 118
     {
119 119
     }
120 120
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @param PHPUnit_Framework_Test $test
125 125
      */
126
-    public function startTest(PHPUnit_Framework_Test $test)
126
+    public function startTest( PHPUnit_Framework_Test $test )
127 127
     {
128 128
     }
129 129
 
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      * @param PHPUnit_Framework_Test $test
134 134
      * @param float                  $time
135 135
      */
136
-    public function endTest(PHPUnit_Framework_Test $test, $time)
136
+    public function endTest( PHPUnit_Framework_Test $test, $time )
137 137
     {
138
-        if (!$test instanceof PHPUnit_Framework_TestCase) return;
138
+        if ( ! $test instanceof PHPUnit_Framework_TestCase ) return;
139 139
 
140
-        $time = $this->toMilliseconds($time);
141
-        $threshold = $this->getSlowThreshold($test);
140
+        $time = $this->toMilliseconds( $time );
141
+        $threshold = $this->getSlowThreshold( $test );
142 142
 
143
-        if ($this->isSlow($time, $threshold)) {
144
-            $this->addSlowTest($test, $time);
143
+        if ( $this->isSlow( $time, $threshold ) ) {
144
+            $this->addSlowTest( $test, $time );
145 145
         }
146 146
     }
147 147
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      *
151 151
      * @param PHPUnit_Framework_TestSuite $suite
152 152
      */
153
-    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
153
+    public function startTestSuite( PHPUnit_Framework_TestSuite $suite )
154 154
     {
155 155
         $this->suites++;
156 156
     }
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
      *
161 161
      * @param PHPUnit_Framework_TestSuite $suite
162 162
      */
163
-    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
163
+    public function endTestSuite( PHPUnit_Framework_TestSuite $suite )
164 164
     {
165 165
         $this->suites--;
166 166
 
167
-        if (0 === $this->suites && $this->hasSlowTests()) {
168
-            arsort($this->slow); // Sort longest running tests to the top
167
+        if ( 0 === $this->suites && $this->hasSlowTests() ) {
168
+            arsort( $this->slow ); // Sort longest running tests to the top
169 169
 
170 170
             $this->renderHeader();
171 171
             $this->renderBody();
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
181 181
      * @return bool
182 182
      */
183
-    protected function isSlow($time, $slowThreshold)
183
+    protected function isSlow( $time, $slowThreshold )
184 184
     {
185 185
         return $time >= $slowThreshold;
186 186
     }
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
      * @param PHPUnit_Framework_TestCase $test
192 192
      * @param int                        $time Test execution time in milliseconds
193 193
      */
194
-    protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time)
194
+    protected function addSlowTest( PHPUnit_Framework_TestCase $test, $time )
195 195
     {
196
-        $label = $this->makeLabel($test);
196
+        $label = $this->makeLabel( $test );
197 197
 
198
-        $this->slow[$label] = $time;
198
+        $this->slow[ $label ] = $time;
199 199
     }
200 200
 
201 201
     /**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function hasSlowTests()
207 207
     {
208
-        return !empty($this->slow);
208
+        return ! empty( $this->slow );
209 209
     }
210 210
 
211 211
     /**
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
      * @param float $time
215 215
      * @return int
216 216
      */
217
-    protected function toMilliseconds($time)
217
+    protected function toMilliseconds( $time )
218 218
     {
219
-        return (int) round($time * 1000);
219
+        return (int) round( $time * 1000 );
220 220
     }
221 221
 
222 222
     /**
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
      * @param PHPUnit_Framework_TestCase $test
226 226
      * @return string
227 227
      */
228
-    protected function makeLabel(PHPUnit_Framework_TestCase $test)
228
+    protected function makeLabel( PHPUnit_Framework_TestCase $test )
229 229
     {
230
-        return sprintf('%s:%s', get_class($test), $test->getName());
230
+        return sprintf( '%s:%s', get_class( $test ), $test->getName() );
231 231
     }
232 232
 
233 233
     /**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     protected function getReportLength()
239 239
     {
240
-        return min(count($this->slow), $this->reportLength);
240
+        return min( count( $this->slow ), $this->reportLength );
241 241
     }
242 242
 
243 243
     /**
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
      */
248 248
     protected function getHiddenCount()
249 249
     {
250
-        $total = count($this->slow);
251
-        $showing = $this->getReportLength($this->slow);
250
+        $total = count( $this->slow );
251
+        $showing = $this->getReportLength( $this->slow );
252 252
 
253 253
         $hidden = 0;
254
-        if ($total > $showing) {
254
+        if ( $total > $showing ) {
255 255
             $hidden = $total - $showing;
256 256
         }
257 257
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     protected function renderHeader()
265 265
     {
266
-        echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold);
266
+        echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
267 267
     }
268 268
 
269 269
     /**
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
     {
274 274
         $slowTests = $this->slow;
275 275
 
276
-        $length = $this->getReportLength($slowTests);
277
-        for ($i = 1; $i <= $length; ++$i) {
278
-            $label = key($slowTests);
279
-            $time = array_shift($slowTests);
276
+        $length = $this->getReportLength( $slowTests );
277
+        for ( $i = 1; $i <= $length; ++$i ) {
278
+            $label = key( $slowTests );
279
+            $time = array_shift( $slowTests );
280 280
 
281
-            echo sprintf(" %s. %sms to run %s\n", $i, $time, $label);
281
+            echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
282 282
         }
283 283
     }
284 284
 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
      */
288 288
     protected function renderFooter()
289 289
     {
290
-        if ($hidden = $this->getHiddenCount($this->slow)) {
291
-            echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden);
290
+        if ( $hidden = $this->getHiddenCount( $this->slow ) ) {
291
+            echo sprintf( "...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden );
292 292
         }
293 293
     }
294 294
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
      *
298 298
      * @param array $options
299 299
      */
300
-    protected function loadOptions(array $options)
300
+    protected function loadOptions( array $options )
301 301
     {
302
-        $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500;
303
-        $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10;
302
+        $this->slowThreshold = isset( $options[ 'slowThreshold' ] ) ? $options[ 'slowThreshold' ] : 500;
303
+        $this->reportLength = isset( $options[ 'reportLength' ] ) ? $options[ 'reportLength' ] : 10;
304 304
     }
305 305
 
306 306
     /**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
      * @param PHPUnit_Framework_TestCase $test
320 320
      * @return int
321 321
      */
322
-    protected function getSlowThreshold(PHPUnit_Framework_TestCase $test)
322
+    protected function getSlowThreshold( PHPUnit_Framework_TestCase $test )
323 323
     {
324 324
         $ann = $test->getAnnotations();
325 325
 
326
-        return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
326
+        return isset( $ann[ 'method' ][ 'slowThreshold' ][ 0 ] ) ? $ann[ 'method' ][ 'slowThreshold' ][ 0 ] : $this->slowThreshold;
327 327
     }
328 328
 }
Please login to merge, or discard this patch.
Braces   +27 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
  * https://github.com/johnkary/phpunit-speedtrap/
7 7
  *
8 8
  */
9
-class SpeedTrapListener implements PHPUnit_Framework_TestListener
10
-{
9
+class SpeedTrapListener implements PHPUnit_Framework_TestListener {
11 10
     /**
12 11
      * Internal tracking for test suites.
13 12
      *
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
      *
46 45
      * @param array $options
47 46
      */
48
-    public function __construct(array $options = array())
49
-    {
47
+    public function __construct(array $options = array()) {
50 48
         $this->loadOptions($options);
51 49
     }
52 50
 
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
      * @param Exception              $e
58 56
      * @param float                  $time
59 57
      */
60
-    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
61
-    {
58
+    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
62 59
     }
63 60
 
64 61
     /**
@@ -69,8 +66,7 @@  discard block
 block discarded – undo
69 66
      * @param float                     $time
70 67
      * @since Method available since Release 5.1.0
71 68
      */
72
-    public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time)
73
-    {
69
+    public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) {
74 70
     }
75 71
 
76 72
     /**
@@ -80,8 +76,7 @@  discard block
 block discarded – undo
80 76
      * @param PHPUnit_Framework_AssertionFailedError $e
81 77
      * @param float                                  $time
82 78
      */
83
-    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
84
-    {
79
+    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
85 80
     }
86 81
 
87 82
     /**
@@ -91,8 +86,7 @@  discard block
 block discarded – undo
91 86
      * @param Exception              $e
92 87
      * @param float                  $time
93 88
      */
94
-    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
95
-    {
89
+    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
96 90
     }
97 91
 
98 92
     /**
@@ -103,8 +97,7 @@  discard block
 block discarded – undo
103 97
      * @param float                  $time
104 98
      * @since Method available since Release 4.0.0
105 99
      */
106
-    public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
107
-    {
100
+    public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
108 101
     }
109 102
 
110 103
     /**
@@ -114,8 +107,7 @@  discard block
 block discarded – undo
114 107
      * @param Exception              $e
115 108
      * @param float                  $time
116 109
      */
117
-    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
118
-    {
110
+    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
119 111
     }
120 112
 
121 113
     /**
@@ -123,8 +115,7 @@  discard block
 block discarded – undo
123 115
      *
124 116
      * @param PHPUnit_Framework_Test $test
125 117
      */
126
-    public function startTest(PHPUnit_Framework_Test $test)
127
-    {
118
+    public function startTest(PHPUnit_Framework_Test $test) {
128 119
     }
129 120
 
130 121
     /**
@@ -133,9 +124,10 @@  discard block
 block discarded – undo
133 124
      * @param PHPUnit_Framework_Test $test
134 125
      * @param float                  $time
135 126
      */
136
-    public function endTest(PHPUnit_Framework_Test $test, $time)
137
-    {
138
-        if (!$test instanceof PHPUnit_Framework_TestCase) return;
127
+    public function endTest(PHPUnit_Framework_Test $test, $time) {
128
+        if (!$test instanceof PHPUnit_Framework_TestCase) {
129
+        	return;
130
+        }
139 131
 
140 132
         $time = $this->toMilliseconds($time);
141 133
         $threshold = $this->getSlowThreshold($test);
@@ -150,8 +142,7 @@  discard block
 block discarded – undo
150 142
      *
151 143
      * @param PHPUnit_Framework_TestSuite $suite
152 144
      */
153
-    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
154
-    {
145
+    public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
155 146
         $this->suites++;
156 147
     }
157 148
 
@@ -160,8 +151,7 @@  discard block
 block discarded – undo
160 151
      *
161 152
      * @param PHPUnit_Framework_TestSuite $suite
162 153
      */
163
-    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
164
-    {
154
+    public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
165 155
         $this->suites--;
166 156
 
167 157
         if (0 === $this->suites && $this->hasSlowTests()) {
@@ -180,8 +170,7 @@  discard block
 block discarded – undo
180 170
      * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
181 171
      * @return bool
182 172
      */
183
-    protected function isSlow($time, $slowThreshold)
184
-    {
173
+    protected function isSlow($time, $slowThreshold) {
185 174
         return $time >= $slowThreshold;
186 175
     }
187 176
 
@@ -191,8 +180,7 @@  discard block
 block discarded – undo
191 180
      * @param PHPUnit_Framework_TestCase $test
192 181
      * @param int                        $time Test execution time in milliseconds
193 182
      */
194
-    protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time)
195
-    {
183
+    protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time) {
196 184
         $label = $this->makeLabel($test);
197 185
 
198 186
         $this->slow[$label] = $time;
@@ -203,8 +191,7 @@  discard block
 block discarded – undo
203 191
      *
204 192
      * @return bool
205 193
      */
206
-    protected function hasSlowTests()
207
-    {
194
+    protected function hasSlowTests() {
208 195
         return !empty($this->slow);
209 196
     }
210 197
 
@@ -214,8 +201,7 @@  discard block
 block discarded – undo
214 201
      * @param float $time
215 202
      * @return int
216 203
      */
217
-    protected function toMilliseconds($time)
218
-    {
204
+    protected function toMilliseconds($time) {
219 205
         return (int) round($time * 1000);
220 206
     }
221 207
 
@@ -225,8 +211,7 @@  discard block
 block discarded – undo
225 211
      * @param PHPUnit_Framework_TestCase $test
226 212
      * @return string
227 213
      */
228
-    protected function makeLabel(PHPUnit_Framework_TestCase $test)
229
-    {
214
+    protected function makeLabel(PHPUnit_Framework_TestCase $test) {
230 215
         return sprintf('%s:%s', get_class($test), $test->getName());
231 216
     }
232 217
 
@@ -235,8 +220,7 @@  discard block
 block discarded – undo
235 220
      *
236 221
      * @return int
237 222
      */
238
-    protected function getReportLength()
239
-    {
223
+    protected function getReportLength() {
240 224
         return min(count($this->slow), $this->reportLength);
241 225
     }
242 226
 
@@ -245,8 +229,7 @@  discard block
 block discarded – undo
245 229
      *
246 230
      * @return int Number of hidden slow tests
247 231
      */
248
-    protected function getHiddenCount()
249
-    {
232
+    protected function getHiddenCount() {
250 233
         $total = count($this->slow);
251 234
         $showing = $this->getReportLength($this->slow);
252 235
 
@@ -261,16 +244,14 @@  discard block
 block discarded – undo
261 244
     /**
262 245
      * Renders slow test report header.
263 246
      */
264
-    protected function renderHeader()
265
-    {
247
+    protected function renderHeader() {
266 248
         echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold);
267 249
     }
268 250
 
269 251
     /**
270 252
      * Renders slow test report body.
271 253
      */
272
-    protected function renderBody()
273
-    {
254
+    protected function renderBody() {
274 255
         $slowTests = $this->slow;
275 256
 
276 257
         $length = $this->getReportLength($slowTests);
@@ -285,8 +266,7 @@  discard block
 block discarded – undo
285 266
     /**
286 267
      * Renders slow test report footer.
287 268
      */
288
-    protected function renderFooter()
289
-    {
269
+    protected function renderFooter() {
290 270
         if ($hidden = $this->getHiddenCount($this->slow)) {
291 271
             echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden);
292 272
         }
@@ -297,8 +277,7 @@  discard block
 block discarded – undo
297 277
      *
298 278
      * @param array $options
299 279
      */
300
-    protected function loadOptions(array $options)
301
-    {
280
+    protected function loadOptions(array $options) {
302 281
         $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500;
303 282
         $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10;
304 283
     }
@@ -319,8 +298,7 @@  discard block
 block discarded – undo
319 298
      * @param PHPUnit_Framework_TestCase $test
320 299
      * @return int
321 300
      */
322
-    protected function getSlowThreshold(PHPUnit_Framework_TestCase $test)
323
-    {
301
+    protected function getSlowThreshold(PHPUnit_Framework_TestCase $test) {
324 302
         $ann = $test->getAnnotations();
325 303
 
326 304
         return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
Please login to merge, or discard this patch.
vendor/extended-cpts/tests/phpunit/includes/bootstrap.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$_tests_dir = getenv('WP_TESTS_DIR');
4
-if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
3
+$_tests_dir = getenv( 'WP_TESTS_DIR' );
4
+if ( ! $_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
5 5
 
6 6
 require_once $_tests_dir . '/includes/functions.php';
7 7
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $_tests_dir = getenv('WP_TESTS_DIR');
4
-if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
4
+if ( !$_tests_dir ) {
5
+	$_tests_dir = '/tmp/wordpress-tests-lib';
6
+}
5 7
 
6 8
 require_once $_tests_dir . '/includes/functions.php';
7 9
 
Please login to merge, or discard this patch.
vendor/extended-cpts/tests/phpunit/extended-cpts-test.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$wp_rewrite->init();
15 15
 		$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
16 16
 
17
-		$this->args['hello'] = array(
17
+		$this->args[ 'hello' ] = array(
18 18
 			'site_sortables' => array(
19 19
 				'test_site_sortables_post_meta' => array(
20 20
 					'meta_key' => 'test_meta_key',
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			'query_var' => 'hi',
81 81
 		);
82 82
 
83
-		$this->cpts['hello']  = register_extended_post_type( 'hello', $this->args['hello'] );
84
-		$this->cpts['hello']->add_taxonomy( 'hello_category' );
83
+		$this->cpts[ 'hello' ]  = register_extended_post_type( 'hello', $this->args[ 'hello' ] );
84
+		$this->cpts[ 'hello' ]->add_taxonomy( 'hello_category' );
85 85
 
86
-		$this->cpts['person'] = register_extended_post_type( 'person', array(
86
+		$this->cpts[ 'person' ] = register_extended_post_type( 'person', array(
87 87
 			'has_archive'    => 'team',
88 88
 			'show_in_feed'   => true,
89 89
 			'site_sortables' => array(
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 		), array(
112 112
 			'plural' => 'People',
113 113
 		) );
114
-		$this->cpts['person']->add_taxonomy( 'person_category' );
115
-		$this->cpts['nice-thing'] = register_extended_post_type( 'nice-thing', array(), array(
114
+		$this->cpts[ 'person' ]->add_taxonomy( 'person_category' );
115
+		$this->cpts[ 'nice-thing' ] = register_extended_post_type( 'nice-thing', array(), array(
116 116
 			'slug' => 'Things',
117 117
 		) );
118
-		$this->cpts['foo'] = register_extended_post_type( 'foo', array(
118
+		$this->cpts[ 'foo' ] = register_extended_post_type( 'foo', array(
119 119
 			'rewrite' => array(
120 120
 				'permastruct' => 'foo/%author%/%foo_category%/%foo%',
121 121
 			),
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 		), array(
124 124
 			'singular' => 'Bar',
125 125
 		) );
126
-		$this->cpts['foo']->add_taxonomy( 'foo_category' );
126
+		$this->cpts[ 'foo' ]->add_taxonomy( 'foo_category' );
127 127
 
128
-		$this->cpts['bar'] = register_extended_post_type( 'bar', array(
128
+		$this->cpts[ 'bar' ] = register_extended_post_type( 'bar', array(
129 129
 			'public'         => false,
130 130
 			'featured_image' => 'Icon',
131 131
 		), array(
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 			'slug'     => 'Slug',
135 135
 		) );
136 136
 
137
-		$this->cpts['baz'] = register_extended_post_type( 'baz', array(
137
+		$this->cpts[ 'baz' ] = register_extended_post_type( 'baz', array(
138 138
 			'rewrite' => array(
139 139
 				'permastruct' => 'baz/%postname%',
140 140
 			),
141 141
 			'has_archive' => false,
142 142
 		) );
143 143
 
144
-		$this->cpts['post'] = register_extended_post_type( 'post', array(
144
+		$this->cpts[ 'post' ] = register_extended_post_type( 'post', array(
145 145
 			'labels' => array(
146 146
 				'remove_featured_image' => 'Remove!',
147 147
 			),
@@ -155,79 +155,79 @@  discard block
 block discarded – undo
155 155
 		}
156 156
 
157 157
 		// Post
158
-		$this->posts['post'][] = $this->factory->post->create( array(
158
+		$this->posts[ 'post' ][ ] = $this->factory->post->create( array(
159 159
 			'guid'      => 'guid',
160 160
 			'post_type' => 'post',
161 161
 			'post_date' => '1984-02-25 00:05:00'
162 162
 		) );
163 163
 
164 164
 		// Hello 0
165
-		$this->posts['hello'][0] = $this->factory->post->create( array(
165
+		$this->posts[ 'hello' ][ 0 ] = $this->factory->post->create( array(
166 166
 			'guid'      => 'guid',
167 167
 			'post_type' => 'hello',
168 168
 			'post_name' => 'Alpha',
169 169
 			'post_date' => '1984-02-25 00:04:00'
170 170
 		) );
171
-		add_post_meta( $this->posts['hello'][0], 'test_meta_key', 'Delta' );
172
-		wp_add_object_terms( $this->posts['hello'][0], 'Beta', 'hello_category' );
171
+		add_post_meta( $this->posts[ 'hello' ][ 0 ], 'test_meta_key', 'Delta' );
172
+		wp_add_object_terms( $this->posts[ 'hello' ][ 0 ], 'Beta', 'hello_category' );
173 173
 
174 174
 		// Hello 1
175
-		$this->posts['hello'][1] = $this->factory->post->create( array(
175
+		$this->posts[ 'hello' ][ 1 ] = $this->factory->post->create( array(
176 176
 			'guid'      => 'guid',
177 177
 			'post_type' => 'hello',
178 178
 			'post_name' => 'Delta',
179 179
 			'post_date' => '1984-02-25 00:03:00'
180 180
 		) );
181
-		add_post_meta( $this->posts['hello'][1], 'test_meta_key', 'Alpha' );
181
+		add_post_meta( $this->posts[ 'hello' ][ 1 ], 'test_meta_key', 'Alpha' );
182 182
 
183 183
 		// Hello 2
184
-		$this->posts['hello'][2] = $this->factory->post->create( array(
184
+		$this->posts[ 'hello' ][ 2 ] = $this->factory->post->create( array(
185 185
 			'guid'      => 'guid',
186 186
 			'post_type' => 'hello',
187 187
 			'post_name' => 'Beta',
188 188
 			'post_date' => '1984-02-25 00:02:00'
189 189
 		) );
190
-		add_post_meta( $this->posts['hello'][2], 'test_meta_key', 'Beta' );
191
-		wp_add_object_terms( $this->posts['hello'][2], 'Alpha', 'hello_category' );
190
+		add_post_meta( $this->posts[ 'hello' ][ 2 ], 'test_meta_key', 'Beta' );
191
+		wp_add_object_terms( $this->posts[ 'hello' ][ 2 ], 'Alpha', 'hello_category' );
192 192
 
193 193
 		// Hello 3
194
-		$this->posts['hello'][3] = $this->factory->post->create( array(
194
+		$this->posts[ 'hello' ][ 3 ] = $this->factory->post->create( array(
195 195
 			'guid'      => 'guid',
196 196
 			'post_type' => 'hello',
197 197
 			'post_name' => 'Gamma',
198 198
 			'post_date' => '1984-02-25 00:01:00'
199 199
 		) );
200
-		wp_add_object_terms( $this->posts['hello'][3], 'Gamma', 'hello_category' );
200
+		wp_add_object_terms( $this->posts[ 'hello' ][ 3 ], 'Gamma', 'hello_category' );
201 201
 
202
-		$this->posts['person'][0] = $this->factory->post->create( array(
202
+		$this->posts[ 'person' ][ 0 ] = $this->factory->post->create( array(
203 203
 			'guid'      => 'guid',
204 204
 			'post_type' => 'person',
205 205
 			'post_name' => 'Beta',
206 206
 			'post_date' => '1984-02-25 00:01:00'
207 207
 		) );
208
-		$this->posts['person'][1] = $this->factory->post->create( array(
208
+		$this->posts[ 'person' ][ 1 ] = $this->factory->post->create( array(
209 209
 			'guid'      => 'guid',
210 210
 			'post_type' => 'person',
211 211
 			'post_name' => 'Alpha',
212 212
 			'post_date' => '1984-02-25 00:02:00'
213 213
 		) );
214
-		$this->posts['nice-thing'][0] = $this->factory->post->create( array(
214
+		$this->posts[ 'nice-thing' ][ 0 ] = $this->factory->post->create( array(
215 215
 			'guid'      => 'guid',
216 216
 			'post_type' => 'nice-thing',
217 217
 		) );
218
-		$this->posts['foo'][0] = $this->factory->post->create( array(
218
+		$this->posts[ 'foo' ][ 0 ] = $this->factory->post->create( array(
219 219
 			'guid'        => 'guid',
220 220
 			'post_type'   => 'foo',
221 221
 			'post_author' => 1,
222 222
 		) );
223
-		wp_add_object_terms( $this->posts['foo'][0], array( 'Gamma', 'Delta' ), 'foo_category' );
223
+		wp_add_object_terms( $this->posts[ 'foo' ][ 0 ], array( 'Gamma', 'Delta' ), 'foo_category' );
224 224
 
225
-		$this->posts['bar'][0] = $this->factory->post->create( array(
225
+		$this->posts[ 'bar' ][ 0 ] = $this->factory->post->create( array(
226 226
 			'guid'        => 'guid',
227 227
 			'post_type'   => 'bar',
228 228
 		) );
229 229
 
230
-		$this->posts['baz'][0] = $this->factory->post->create( array(
230
+		$this->posts[ 'baz' ][ 0 ] = $this->factory->post->create( array(
231 231
 			'guid'        => 'guid',
232 232
 			'post_type'   => 'baz',
233 233
 		) );
Please login to merge, or discard this patch.
vendor/extended-cpts/tests/phpunit/extended-cpts-test-admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 		$_GET = $_REQUEST = $args;
18 18
 
19
-		$GLOBALS['hook_suffix'] = 'edit.php';
19
+		$GLOBALS[ 'hook_suffix' ] = 'edit.php';
20 20
 
21
-		set_current_screen( 'edit-' . $args['post_type'] );
21
+		set_current_screen( 'edit-' . $args[ 'post_type' ] );
22 22
 		do_action( 'load-edit.php' );
23 23
 
24 24
 		wp_set_current_user( 1 ); // @TODO change
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
27 27
 
28 28
 		$this->assertSame( 'edit', get_current_screen()->base );
29
-		$this->assertSame( $args['post_type'], get_current_screen()->post_type );
29
+		$this->assertSame( $args[ 'post_type' ], get_current_screen()->post_type );
30 30
 		$this->assertInstanceOf( 'WP_List_Table', $wp_list_table );
31 31
 
32 32
 		ob_start();
Please login to merge, or discard this patch.