Skip to content

Commit 2e9ab30

Browse files
Fix CS/WS issues
1 parent 1a3f78e commit 2e9ab30

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

src/Framework/TestResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ class TestResult implements Countable
177177
/**
178178
* @var bool
179179
*/
180-
private $stopOnDefect = false;
180+
protected $lastTestFailed = false;
181181

182182
/**
183183
* @var bool
184184
*/
185-
protected $lastTestFailed = false;
185+
private $stopOnDefect = false;
186186

187187
/**
188188
* @var bool

src/Runner/ResultCacheExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,54 @@ public function flush(): void
2929
public function executeAfterSuccessfulTest(string $test, float $time): void
3030
{
3131
$testName = $this->getTestName($test);
32+
3233
$this->cache->setTime($testName, \round($time, 3));
3334
}
3435

3536
public function executeAfterIncompleteTest(string $test, string $message, float $time): void
3637
{
3738
$testName = $this->getTestName($test);
39+
3840
$this->cache->setTime($testName, \round($time, 3));
3941
$this->cache->setState($testName, BaseTestRunner::STATUS_INCOMPLETE);
4042
}
4143

4244
public function executeAfterRiskyTest(string $test, string $message, float $time): void
4345
{
4446
$testName = $this->getTestName($test);
47+
4548
$this->cache->setTime($testName, \round($time, 3));
4649
$this->cache->setState($testName, BaseTestRunner::STATUS_RISKY);
4750
}
4851

4952
public function executeAfterSkippedTest(string $test, string $message, float $time): void
5053
{
5154
$testName = $this->getTestName($test);
55+
5256
$this->cache->setTime($testName, \round($time, 3));
5357
$this->cache->setState($testName, BaseTestRunner::STATUS_SKIPPED);
5458
}
5559

5660
public function executeAfterTestError(string $test, string $message, float $time): void
5761
{
5862
$testName = $this->getTestName($test);
63+
5964
$this->cache->setTime($testName, \round($time, 3));
6065
$this->cache->setState($testName, BaseTestRunner::STATUS_ERROR);
6166
}
6267

6368
public function executeAfterTestFailure(string $test, string $message, float $time): void
6469
{
6570
$testName = $this->getTestName($test);
71+
6672
$this->cache->setTime($testName, \round($time, 3));
6773
$this->cache->setState($testName, BaseTestRunner::STATUS_FAILURE);
6874
}
6975

7076
public function executeAfterTestWarning(string $test, string $message, float $time): void
7177
{
7278
$testName = $this->getTestName($test);
79+
7380
$this->cache->setTime($testName, \round($time, 3));
7481
$this->cache->setState($testName, BaseTestRunner::STATUS_WARNING);
7582
}

src/Runner/TestSuiteSorter.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function reorderTestsInSuite(Test $suite, int $order, bool $resolveDepend
8989
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
9090
$this->addSuiteToDefectSortOrder($suite);
9191
}
92+
9293
$this->sort($suite, $order, $resolveDependencies, $orderDefects);
9394
}
9495
}
@@ -130,9 +131,13 @@ private function addSuiteToDefectSortOrder(TestSuite $suite): void
130131

131132
private function suiteOnlyContainsTests(TestSuite $suite): bool
132133
{
133-
return \array_reduce($suite->tests(), function ($carry, $test) {
134-
return $carry && ($test instanceof TestCase || $test instanceof DataProviderTestSuite);
135-
}, true);
134+
return \array_reduce(
135+
$suite->tests(),
136+
function ($carry, $test) {
137+
return $carry && ($test instanceof TestCase || $test instanceof DataProviderTestSuite);
138+
},
139+
true
140+
);
136141
}
137142

138143
private function reverse(array $tests): array
@@ -149,9 +154,12 @@ private function randomize(array $tests): array
149154

150155
private function sortDefectsFirst(array $tests): array
151156
{
152-
\usort($tests, function ($left, $right) {
153-
return $this->cmpDefectPriorityAndTime($left, $right);
154-
});
157+
\usort(
158+
$tests,
159+
function ($left, $right) {
160+
return $this->cmpDefectPriorityAndTime($left, $right);
161+
}
162+
);
155163

156164
return $tests;
157165
}
@@ -202,9 +210,12 @@ private function resolveDependencies(array $tests): array
202210
$i = 0;
203211

204212
do {
205-
$todoNames = \array_map(function ($test) {
206-
return $this->getNormalizedTestName($test);
207-
}, $tests);
213+
$todoNames = \array_map(
214+
function ($test) {
215+
return $this->getNormalizedTestName($test);
216+
},
217+
$tests
218+
);
208219

209220
if (!$tests[$i]->hasDependencies() || empty(\array_intersect($this->getNormalizedDependencyNames($tests[$i]), $todoNames))) {
210221
$newTestOrder = \array_merge($newTestOrder, \array_splice($tests, $i, 1));
@@ -244,11 +255,12 @@ private function getNormalizedDependencyNames($test): array
244255
$testClass = \get_class($test);
245256
}
246257

247-
$names = \array_map(function ($name) use ($testClass) {
248-
return \strpos($name, '::') === false
249-
? $testClass . '::' . $name
250-
: $name;
251-
}, $test->getDependencies());
258+
$names = \array_map(
259+
function ($name) use ($testClass) {
260+
return \strpos($name, '::') === false ? $testClass . '::' . $name : $name;
261+
},
262+
$test->getDependencies()
263+
);
252264

253265
return $names;
254266
}

src/TextUI/Command.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,22 +1330,27 @@ private function handleOrderByOption(string $value): void
13301330
$this->arguments['resolveDependencies'] = false;
13311331

13321332
break;
1333+
13331334
case 'reverse':
13341335
$this->arguments['executionOrder'] = TestSuiteSorter::ORDER_REVERSED;
13351336

13361337
break;
1338+
13371339
case 'random':
13381340
$this->arguments['executionOrder'] = TestSuiteSorter::ORDER_RANDOMIZED;
13391341

13401342
break;
1343+
13411344
case 'defects':
13421345
$this->arguments['executionOrderDefects'] = TestSuiteSorter::ORDER_DEFECTS_FIRST;
13431346

13441347
break;
1348+
13451349
case 'depends':
13461350
$this->arguments['resolveDependencies'] = true;
13471351

13481352
break;
1353+
13491354
default:
13501355
$this->exitWithErrorMessage("unrecognized --order-by option: $order");
13511356
}

src/TextUI/TestRunner.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,17 @@ public function doRun(Test $suite, array $arguments = [], bool $exit = true): Te
183183
} else {
184184
$cache = new TestResultCache;
185185
}
186+
186187
$this->extensions[] = new ResultCacheExtension($cache);
187188
}
188189

189190
if ($arguments['executionOrder'] !== TestSuiteSorter::ORDER_DEFAULT || $arguments['executionOrderDefects'] !== TestSuiteSorter::ORDER_DEFAULT || $arguments['resolveDependencies']) {
190191
if (!isset($cache)) {
191192
$cache = new NullTestResultCache;
192193
}
194+
193195
$cache->load();
196+
194197
$sorter = new TestSuiteSorter($cache);
195198

196199
$sorter->reorderTestsInSuite($suite, $arguments['executionOrder'], $arguments['resolveDependencies'], $arguments['executionOrderDefects']);

0 commit comments

Comments
 (0)