Skip to content

Commit

Permalink
Fix deprecation warning if trailing slash in path is omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl authored and sebastianbergmann committed Dec 10, 2019
1 parent ea4e631 commit 31e2d93
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/TextUI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +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) !== '/') {
\substr($this->options[1][0], -1, 1) !== '/' &&
!\is_dir($this->options[1][0])) {
$this->arguments['warnings'][] = 'Invocation with class name is deprecated';
}

Expand Down
17 changes: 17 additions & 0 deletions tests/end-to-end/regression/GitHub/3983-2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
phpunit 3983/
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = __DIR__ . '/3983/';

require __DIR__ . '/../../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

. 1 / 1 (100%)

Time: %s, Memory: %s

OK (1 test, 1 assertion)
17 changes: 17 additions & 0 deletions tests/end-to-end/regression/GitHub/3983.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
phpunit 3983/
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = __DIR__ . '/3983';

require __DIR__ . '/../../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

. 1 / 1 (100%)

Time: %s, Memory: %s

OK (1 test, 1 assertion)
18 changes: 18 additions & 0 deletions tests/end-to-end/regression/GitHub/3983/Issue3983Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPUnit\Framework\TestCase;

final class Issue3983Test extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}

0 comments on commit 31e2d93

Please sign in to comment.