The Invocation with class name is deprecated warning is printed when a directory (and not a class name) is given:
$ tree
.
โโโ build
โย ย โโโ code-coverage
โย ย โโโ CanvasIterator.php.html
โย ย โโโ Canvas.php.html
โย ย โโโ Color.php.html
โย ย โโโ dashboard.html
โย ย โโโ exceptions
โย ย โย ย โโโ dashboard.html
โย ย โย ย โโโ Exception.php.html
โย ย โย ย โโโ index.html
โย ย โย ย โโโ InvalidArgumentException.php.html
โย ย โย ย โโโ RuntimeException.php.html
โย ย โโโ index.html
โย ย โโโ Matrix.php.html
โย ย โโโ PortablePixmapMapper.php.html
โย ย โโโ Tuple.php.html
โโโ build.xml
โโโ phive.xml
โโโ phpunit.xml
โโโ psalm.xml
โโโ README.md
โโโ src
โย ย โโโ autoload.php
โย ย โโโ CanvasIterator.php
โย ย โโโ Canvas.php
โย ย โโโ Color.php
โย ย โโโ exceptions
โย ย โย ย โโโ Exception.php
โย ย โย ย โโโ InvalidArgumentException.php
โย ย โย ย โโโ RuntimeException.php
โย ย โโโ Matrix.php
โย ย โโโ PortablePixmapMapper.php
โย ย โโโ Tuple.php
โโโ tests
โย ย โโโ CanvasTest.php
โย ย โโโ ColorTest.php
โย ย โโโ fixture
โย ย โย ย โโโ 10_20_empty.ppm
โย ย โโโ MatrixTest.php
โย ย โโโ PortablePixmapMapperTest.php
โย ย โโโ TupleTest.php
โโโ tools
โโโ phpab
โโโ php-cs-fixer
โโโ phpunit
โโโ phpunit.phar -> phpunit
โโโ psalm
8 directories, 39 files
$ ./tools/phpunit tests
PHPUnit 8.5.0 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.0 with PCOV 1.0.6
Configuration: /usr/local/src/raytracer/phpunit.xml
Warning: Invocation with class name is deprecated
...................................S....................... 59 / 59 (100%)
Time: 82 ms, Memory: 10.00 MB
There was 1 skipped test:
1) SebastianBergmann\Raytracer\MatrixTest::test_the_product_of_two_matrices_can_be_multiplied_by_its_inverse
/usr/local/src/raytracer/tests/MatrixTest.php:528
OK, but incomplete, skipped, or risky tests!
Tests: 59, Assertions: 385, Skipped: 1.
CC @flow-control
I'll have a look
Thanks!
Hey Sebastian,
this is due to the "missing" trailing slash. I added tests for this and a is_dir check.
/Flo
Thank for fixing this!
:+1: just stumbled across this issue, thanks y'all for being so quick to address it :)
I still have this issue how to get ride of that ?
Testing started at 1:41 AM ...
C:\xampp\php\php.exe C:/xampp/htdocs/Project/vendor/phpunit/phpunit/phpunit --configuration C:\xampp\htdocs\Project\phpunit.xml --filter "/(::it_has_a_path)( .*)?$/" Tests\Unit\ThreadTest C:\xampp\htdocs\Project\tests\Unit\ThreadTest.php --teamcity --cache-result-file=C:\xampp\htdocs\Project\.phpunit.result.cache
PHPUnit 8.5.0 by Sebastian Bergmann and contributors.
Warning: Invocation with class name is deprecated
Time: 321 ms, Memory: 26.00 MB
OK (1 test, 1 assertion)
Process finished with exit code 0
one thing, I updated my phpunit to the last version, But i cannot see changes of this PR on my phpunit why?
Hey @foremtehan
try without Tests\Unit\ThreadTest in the call, that should do the trick.
Kind regards
Flo
@flow-control That path/namespace picked by phpstorm automatically :
How to prevent this ? Normally i do test my methods by mouse hovering around the method name and hit the shortcut key to run the test
Does the problem persist with PHPUnit 8.5.1?
@sebastianbergmann still Yes:
Testing started at 8:36 PM ...
C:\xampp\php\php.exe C:/xampp/htdocs/Project/vendor/phpunit/phpunit/phpunit --configuration C:\xampp\htdocs\Project\phpunit.xml --filter "/(::it_has_path)( .*)?$/" Tests\Unit\ThreadTest C:\xampp\htdocs\Project\tests\Unit\ThreadTest.php --teamcity --cache-result-file=C:\xampp\htdocs\Project\.phpunit.result.cache
PHPUnit 8.5.1 by Sebastian Bergmann and contributors.
Warning: Invocation with class name is deprecated
Time: 319 ms, Memory: 26.00 MB
OK (1 test, 1 assertion)
Process finished with exit code 0
@sebastianbergmann / @foremtehan as I see it, the generated command has the class name in it, which is deprecated. Omitting the class name will fix it. If you have multiple classes in one file, you can use the filter as described here https://github.com/sebastianbergmann/phpunit/pull/3860#issuecomment-564011548
Also in this thread you can see, that the PHP Storm devs are already up to this
The problem still exists.
/**
* Test if user can add item to wishlist
*
* @test
*
* @return void
* @author Vladimir Nikolic<[email protected]>
*
*/
public function it_ads_item_to_wishlist()
{
$user = factory(\App\User::class)->create();
// see if user have any wishlist
$this->assertEquals(null, $user->wishlist);
}
Result:
Testing started at 10:57 ...
/usr/local/Cellar/php/7.3.11/bin/php /Users/vladimir/Projects/agrilaravel/vendor/phpunit/phpunit/phpunit --configuration /Users/vladimir/Projects/agrilaravel/phpunit.xml --filter "/(::it_ads_item_to_wishlist)( .*)?$/" Tests\Feature\WishlistTest /Users/vladimir/Projects/agrilaravel/tests/Feature/WishlistTest.php --teamcity --cache-result-file=/Users/vladimir/Projects/agrilaravel/.phpunit.result.cache
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Warning: Invocation with class name is deprecated
Time: 343 ms, Memory: 30.00 MB
OK (1 test, 1 assertion)
Process finished with exit code 0
@nezaboravi You have Tests\Feature\WishlistTest in your invocation. This is a test class name. Hence the "Invocation with class name is deprecated" warning is given correctly.
From the phpstorm team:
We've already fixed the issue and the fix should be available in 2019.3.x update
Yes, fixed with latest PHPStorm update, not showing anymore
Fix has been rollbacked according to https://youtrack.jetbrains.com/issue/WI-50201#focus=streamItem-27-3922274.0-0
Most helpful comment
Hey Sebastian,
this is due to the "missing" trailing slash. I added tests for this and a
is_dircheck./Flo