Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 5, 2019
1 parent 03dc427 commit f40603d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/TextUI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Command
'useDefaultConfiguration' => true,
'loadedExtensions' => [],
'notLoadedExtensions' => [],
'warnings' => [],
];

/**
Expand Down Expand Up @@ -782,9 +783,8 @@ protected function handleArguments(array $argv): void
if (isset($this->options[1][0]) &&
\substr($this->options[1][0], -5, 5) !== '.phpt' &&
\substr($this->options[1][0], -4, 4) !== '.php' &&
\substr($this->options[1][0], -1, 1) !== '/'
) {
print 'Warning: Calling PHPUnit with a class name is deprecated and will be removed in PHPUnit 9.' . \PHP_EOL;
\substr($this->options[1][0], -1, 1) !== '/') {
$this->arguments['warnings'][] = 'Invocation with class name is deprecated';
}

if (!isset($this->arguments['test'])) {
Expand Down
4 changes: 4 additions & 0 deletions src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ public function doRun(Test $suite, array $arguments = [], bool $exit = true): Te
}
}

foreach ($arguments['warnings'] as $warning) {
$this->writeMessage('Warning', $warning);
}

if ($arguments['executionOrder'] === TestSuiteSorter::ORDER_RANDOMIZED) {
$this->writeMessage(
'Random seed',
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/abstract-test-class.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ $_SERVER['argv'][3] = __DIR__ . '/../_files/AbstractTest.php';
require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
Warning: Calling PHPUnit with a class name is deprecated and will be removed in PHPUnit 9.
PHPUnit %s by Sebastian Bergmann and contributors.

Warning: Invocation with class name is deprecated

W 1 / 1 (100%)

Time: %s, Memory: %s
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/cli/deprecation-warning-with-class.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ $_SERVER['argv'][3] = __DIR__ . '/../../_files/DummyFooTest.php';
require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
Warning: Calling PHPUnit with a class name is deprecated and will be removed in PHPUnit 9.
PHPUnit %s by Sebastian Bergmann and contributors.

Warning: Invocation with class name is deprecated

. 1 / 1 (100%)

Time: %s, Memory: %s
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/regression/GitHub/3904.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ require __DIR__ . '/../../../bootstrap.php';

PHPUnit\TextUI\Command::main();
--EXPECTF--
Warning: Calling PHPUnit with a class name is deprecated and will be removed in PHPUnit 9.
PHPUnit %s by Sebastian Bergmann and contributors.

Warning: Invocation with class name is deprecated

. 1 / 1 (100%)

Time: %s, Memory: %s
Expand Down
1 change: 0 additions & 1 deletion tests/end-to-end/regression/GitHub/3904_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ try {
}
?>
--EXPECTF--
Warning: Calling PHPUnit with a class name is deprecated and will be removed in PHPUnit 9.
Class 'Issue3904' could not be found in '%s'.

0 comments on commit f40603d

Please sign in to comment.