Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deprecation warning when called with just a class name #3860

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/TextUI/Command.php
Expand Up @@ -780,6 +780,14 @@ protected function handleArguments(array $argv): void
$this->arguments['testSuffixes'] = ['Test.php', '.phpt'];
}

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;
}

if (!isset($this->arguments['test'])) {
if (isset($this->options[1][0])) {
$this->arguments['test'] = $this->options[1][0];
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/abstract-test-class.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit AbstractTest ../../_files/AbstractTest.php
phpunit ../../_files/AbstractTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
Expand All @@ -9,6 +9,7 @@ $_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.

W 1 / 1 (100%)
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/assertion.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit AssertionExampleTest ../../_files/AssertionExampleTest.php
phpunit ../../_files/AssertionExampleTest.php
--SKIPIF--
<?php declare(strict_types=1);
if (PHP_MAJOR_VERSION < 7) {
Expand All @@ -16,8 +16,7 @@ if (ini_get('assert.exception') != 1) {
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'AssertionExampleTest';
$_SERVER['argv'][3] = __DIR__ . '/../_files/AssertionExampleTest.php';
$_SERVER['argv'][2] = __DIR__ . '/../_files/AssertionExampleTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/cli/columns-max.phpt
@@ -1,11 +1,10 @@
--TEST--
phpunit --columns=max BankAccountTest ../../_files/BankAccountTest.php
phpunit --columns=max ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--columns=max';
$_SERVER['argv'][3] = 'BankAccountTest';
$_SERVER['argv'][4] = __DIR__ . '/../../_files/BankAccountTest.php';
$_SERVER['argv'][3] = __DIR__ . '/../../_files/BankAccountTest.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/cli/columns.phpt
@@ -1,11 +1,10 @@
--TEST--
phpunit --columns=40 BankAccountTest ../../_files/BankAccountTest.php
phpunit --columns=40 ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--columns=40';
$_SERVER['argv'][3] = 'BankAccountTest';
$_SERVER['argv'][4] = __DIR__ . '/../../_files/BankAccountTest.php';
$_SERVER['argv'][3] = __DIR__ . '/../../_files/BankAccountTest.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
19 changes: 19 additions & 0 deletions tests/end-to-end/cli/deprecation-warning-with-class.phpt
@@ -0,0 +1,19 @@
--TEST--
phpunit DummyFooTest ../../_files/DummyFooTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'DummyFooTest';
$_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.

. 1 / 1 (100%)

Time: %s, Memory: %s

OK (1 test, 1 assertion)
3 changes: 1 addition & 2 deletions tests/end-to-end/cli/mycommand.phpt
@@ -1,12 +1,11 @@
--TEST--
phpunit BankAccountTest ../../_files/BankAccountTest.php
phpunit ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'--my-option=123',
'--my-other-option',
'BankAccountTest',
\realpath(__DIR__ . '/../../_files/BankAccountTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/cli/options-after-arguments.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit BankAccountTest ../../_files/BankAccountTest.php --colors
phpunit ../../_files/BankAccountTest.php --colors
--FILE--
<?php declare(strict_types=1);
$arguments = [
Expand Down
4 changes: 1 addition & 3 deletions tests/end-to-end/cli/test-file-not-found.phpt
@@ -1,12 +1,10 @@
--TEST--
Test incorrect testFile is reported
--ARGS--
--no-configuration tests nonExistingFile.php
--no-configuration nonExistingFile.php
--FILE--
<?php declare(strict_types=1);
require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Cannot open file "nonExistingFile.php".
2 changes: 1 addition & 1 deletion tests/end-to-end/code-coverage-ignore.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit --colors=never --coverage-text=php://stdout IgnoreCodeCoverageClassTest ../../_files/IgnoreCodeCoverageClassTest.php --whitelist ../../../tests/_files/IgnoreCodeCoverageClass.php
phpunit --colors=never --coverage-text=php://stdout ../../_files/IgnoreCodeCoverageClassTest.php --whitelist ../../../tests/_files/IgnoreCodeCoverageClass.php
--SKIPIF--
<?php declare(strict_types=1);
if (!extension_loaded('xdebug')) {
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/concrete-test-class.phpt
@@ -1,10 +1,9 @@
--TEST--
phpunit ConcreteTest ../../_files/ConcreteTest.php
phpunit ../../_files/ConcreteTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'ConcreteTest';
$_SERVER['argv'][3] = __DIR__ . '/../_files/ConcreteTest.php';
$_SERVER['argv'][2] = __DIR__ . '/../_files/ConcreteTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
4 changes: 2 additions & 2 deletions tests/end-to-end/dataprovider-issue-2833.phpt
@@ -1,9 +1,9 @@
--TEST--
phpunit ../../_files/DataProviderIssue2833
phpunit ../../_files/DataProviderIssue2833/
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = __DIR__ . '/../_files/DataProviderIssue2833';
$_SERVER['argv'][2] = __DIR__ . '/../_files/DataProviderIssue2833/';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
4 changes: 2 additions & 2 deletions tests/end-to-end/dataprovider-issue-2922.phpt
@@ -1,10 +1,10 @@
--TEST--
phpunit --exclude-group=foo ../../_files/DataProviderIssue2922
phpunit --exclude-group=foo ../../_files/DataProviderIssue2922/
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--exclude-group=foo';
$_SERVER['argv'][3] = __DIR__ . '/../_files/DataProviderIssue2922';
$_SERVER['argv'][3] = __DIR__ . '/../_files/DataProviderIssue2922/';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/dataprovider-log-xml-isolation.phpt
@@ -1,13 +1,12 @@
--TEST--
phpunit --process-isolation --log-junit php://stdout DataProviderTest ../../_files/DataProviderTest.php
phpunit --process-isolation --log-junit php://stdout ../../_files/DataProviderTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = '--log-junit';
$_SERVER['argv'][4] = 'php://stdout';
$_SERVER['argv'][5] = 'DataProviderTest';
$_SERVER['argv'][6] = __DIR__ . '/../_files/DataProviderTest.php';
$_SERVER['argv'][5] = __DIR__ . '/../_files/DataProviderTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/dataprovider-log-xml.phpt
@@ -1,12 +1,11 @@
--TEST--
phpunit --log-junit php://stdout DataProviderTest ../../_files/DataProviderTest.php
phpunit --log-junit php://stdout ../../_files/DataProviderTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--log-junit';
$_SERVER['argv'][3] = 'php://stdout';
$_SERVER['argv'][4] = 'DataProviderTest';
$_SERVER['argv'][5] = __DIR__ . '/../_files/DataProviderTest.php';
$_SERVER['argv'][4] = __DIR__ . '/../_files/DataProviderTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/default-isolation.phpt
@@ -1,11 +1,10 @@
--TEST--
phpunit --process-isolation BankAccountTest ../../_files/BankAccountTest.php
phpunit --process-isolation ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = 'BankAccountTest';
$_SERVER['argv'][4] = __DIR__ . '/../_files/BankAccountTest.php';
$_SERVER['argv'][3] = __DIR__ . '/../_files/BankAccountTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/default.phpt
@@ -1,10 +1,9 @@
--TEST--
phpunit BankAccountTest ../../_files/BankAccountTest.php
phpunit ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'BankAccountTest';
$_SERVER['argv'][3] = __DIR__ . '/../_files/BankAccountTest.php';
$_SERVER['argv'][2] = __DIR__ . '/../_files/BankAccountTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/disable-code-coverage-ignore.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit --colors=never --coverage-text=php://stdout --disable-coverage-ignore IgnoreCodeCoverageClassTest tests/_files/IgnoreCodeCoverageClassTest.php --whitelist ../../../tests/_files/IgnoreCodeCoverageClass.php
phpunit --colors=never --coverage-text=php://stdout --disable-coverage-ignore tests/_files/IgnoreCodeCoverageClassTest.php --whitelist ../../../tests/_files/IgnoreCodeCoverageClass.php
--SKIPIF--
<?php declare(strict_types=1);
if (!extension_loaded('xdebug')) {
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/empty-testcase.phpt
@@ -1,10 +1,9 @@
--TEST--
phpunit EmptyTestCaseTest ../../_files/EmptyTestCaseTest.php
phpunit ../../_files/EmptyTestCaseTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'EmptyTestCaseTest';
$_SERVER['argv'][3] = __DIR__ . '/../_files/EmptyTestCaseTest.php';
$_SERVER['argv'][2] = __DIR__ . '/../_files/EmptyTestCaseTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/exception-stack.phpt
@@ -1,10 +1,9 @@
--TEST--
phpunit ExceptionStackTest ../../_files/ExceptionStackTest.php
phpunit ../../_files/ExceptionStackTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = 'ExceptionStackTest';
$_SERVER['argv'][3] = __DIR__ . '/../_files/ExceptionStackTest.php';
$_SERVER['argv'][2] = __DIR__ . '/../_files/ExceptionStackTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/exclude-group-isolation.phpt
@@ -1,13 +1,12 @@
--TEST--
phpunit --process-isolation --exclude-group balanceIsInitiallyZero BankAccountTest ../../_files/BankAccountTest.php
phpunit --process-isolation --exclude-group balanceIsInitiallyZero ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = '--exclude-group';
$_SERVER['argv'][4] = 'balanceIsInitiallyZero';
$_SERVER['argv'][5] = 'BankAccountTest';
$_SERVER['argv'][6] = __DIR__ . '/../_files/BankAccountTest.php';
$_SERVER['argv'][5] = __DIR__ . '/../_files/BankAccountTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/exclude-group.phpt
@@ -1,12 +1,11 @@
--TEST--
phpunit --exclude-group balanceIsInitiallyZero BankAccountTest ../../_files/BankAccountTest.php
phpunit --exclude-group balanceIsInitiallyZero ../../_files/BankAccountTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--exclude-group';
$_SERVER['argv'][3] = 'balanceIsInitiallyZero';
$_SERVER['argv'][4] = 'BankAccountTest';
$_SERVER['argv'][5] = __DIR__ . '/../_files/BankAccountTest.php';
$_SERVER['argv'][4] = __DIR__ . '/../_files/BankAccountTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/execution-order/cache-result.phpt
@@ -1,5 +1,5 @@
--TEST--
phpunit --order-by=no-depends,reverse --cache-result --cache-result-file MultiDependencyTest ./tests/_files/MultiDependencyTest.php
phpunit --order-by=no-depends,reverse --cache-result --cache-result-file ./tests/_files/MultiDependencyTest.php
--FILE--
<?php declare(strict_types=1);
$target = tempnam(sys_get_temp_dir(), __FILE__);
Expand All @@ -10,7 +10,6 @@ $arguments = [
'--order-by=reverse',
'--cache-result',
'--cache-result-file=' . $target,
'MultiDependencyTest',
realpath(__DIR__ . '/../execution-order/_files/MultiDependencyTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
@@ -1,5 +1,5 @@
--TEST--
phpunit --order-by=defects MultiDependencyTest ./tests/_files/MultiDependencyTest.php
phpunit --order-by=defects ./tests/_files/MultiDependencyTest.php
--FILE--
<?php declare(strict_types=1);
$tmpResultCache = \tempnam(sys_get_temp_dir(), __FILE__);
Expand All @@ -11,7 +11,6 @@ $arguments = [
'--order-by=defects',
'--cache-result',
'--cache-result-file=' . $tmpResultCache,
'MultiDependencyTest',
\realpath(__DIR__ . '/_files/MultiDependencyTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/execution-order/dependencies-clone.phpt
@@ -1,11 +1,10 @@
--TEST--
phpunit --verbose ClonedDependencyTest ../../_files/ClonedDependencyTest.php
phpunit --verbose ../../_files/ClonedDependencyTest.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'--verbose',
'ClonedDependencyTest',
\realpath(__DIR__ . '/_files/ClonedDependencyTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/execution-order/dependencies-isolation.phpt
@@ -1,12 +1,11 @@
--TEST--
phpunit --process-isolation --verbose DependencyTestSuite ../../_files/DependencyTestSuite.php
phpunit --process-isolation --verbose ../../_files/DependencyTestSuite.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'--process-isolation',
'--verbose',
'DependencyTestSuite',
\realpath(__DIR__ . '/_files/DependencyTestSuite.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
@@ -1,11 +1,10 @@
--TEST--
phpunit --process-isolation StackTest _files/StackTest.php
phpunit --process-isolation _files/StackTest.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'--process-isolation',
'StackTest',
\realpath(__DIR__ . '/_files/StackTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/execution-order/depends-as-parameter.phpt
@@ -1,10 +1,9 @@
--TEST--
phpunit StackTest _files/StackTest.php
phpunit _files/StackTest.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'StackTest',
\realpath(__DIR__ . '/_files/StackTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down
@@ -1,11 +1,10 @@
--TEST--
phpunit --process-isolation MultiDependencyTest _files/MultiDependencyTest.php
phpunit --process-isolation _files/MultiDependencyTest.php
--FILE--
<?php declare(strict_types=1);
$arguments = [
'--no-configuration',
'--process-isolation',
'MultiDependencyTest',
\realpath(__DIR__ . '/_files/MultiDependencyTest.php'),
];
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
Expand Down