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

Deprecation warning given too eagerly #3983

Closed
sebastianbergmann opened this issue Dec 10, 2019 · 16 comments
Closed

Deprecation warning given too eagerly #3983

sebastianbergmann opened this issue Dec 10, 2019 · 16 comments
Labels
type/bug Something is broken

Comments

@sebastianbergmann
Copy link
Owner

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

@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Dec 10, 2019
@realFlowControl
Copy link
Sponsor Contributor

I'll have a look

@sebastianbergmann
Copy link
Owner Author

Thanks!

@realFlowControl
Copy link
Sponsor Contributor

Hey Sebastian,

this is due to the "missing" trailing slash. I added tests for this and a is_dir check.

/Flo

@TomasVotruba
Copy link

Thank for fixing this!

@erikaheidi
Copy link

erikaheidi commented Dec 18, 2019

👍 just stumbled across this issue, thanks y'all for being so quick to address it :)

@foremtehan
Copy link

foremtehan commented Dec 24, 2019

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?

@realFlowControl
Copy link
Sponsor Contributor

Hey @foremtehan

try without Tests\Unit\ThreadTest in the call, that should do the trick.

Kind regards
Flo

@foremtehan
Copy link

foremtehan commented Dec 25, 2019

@flow-control That path/namespace picked by phpstorm automatically :

Capture

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

@sebastianbergmann
Copy link
Owner Author

Does the problem persist with PHPUnit 8.5.1?

@foremtehan
Copy link

foremtehan commented Dec 25, 2019

@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

@realFlowControl
Copy link
Sponsor Contributor

@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 #3860 (comment)
Also in this thread you can see, that the PHP Storm devs are already up to this

@nezaboravi
Copy link

The problem still exists.

     * Test if user can add item to wishlist
     *
     * @test
     *
     * @return void
     * @author Vladimir Nikolic<vladimir@codingwisely.com>
     *
     */
    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

@sebastianbergmann
Copy link
Owner Author

@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.

@foremtehan
Copy link

From the phpstorm team:

We've already fixed the issue and the fix should be available in 2019.3.x update

https://youtrack.jetbrains.com/issue/WI-50366

@nezaboravi
Copy link

Yes, fixed with latest PHPStorm update, not showing anymore

@safjanowski
Copy link

Fix has been rollbacked according to https://youtrack.jetbrains.com/issue/WI-50201#focus=streamItem-27-3922274.0-0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

7 participants