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

Comments

@sebastianbergmann
Copy link
Owner

@sebastianbergmann sebastianbergmann commented Dec 10, 2019

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

@flow-control
Copy link
Contributor

@flow-control flow-control commented Dec 10, 2019

I'll have a look

Loading

@sebastianbergmann
Copy link
Owner Author

@sebastianbergmann sebastianbergmann commented Dec 10, 2019

Thanks!

Loading

@flow-control
Copy link
Contributor

@flow-control flow-control commented Dec 10, 2019

Hey Sebastian,

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

/Flo

Loading

@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Dec 16, 2019

Thank for fixing this!

Loading

@erikaheidi
Copy link

@erikaheidi erikaheidi commented Dec 18, 2019

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

Loading

@foremtehan
Copy link

@foremtehan 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?

Loading

@flow-control
Copy link
Contributor

@flow-control flow-control commented Dec 25, 2019

Hey @foremtehan

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

Kind regards
Flo

Loading

@foremtehan
Copy link

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

Loading

@sebastianbergmann
Copy link
Owner Author

@sebastianbergmann sebastianbergmann commented Dec 25, 2019

Does the problem persist with PHPUnit 8.5.1?

Loading

@foremtehan
Copy link

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

Loading

@flow-control
Copy link
Contributor

@flow-control flow-control commented Dec 25, 2019

@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

Loading

@nezaboravi
Copy link

@nezaboravi nezaboravi commented Jan 12, 2020

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

Loading

@sebastianbergmann
Copy link
Owner Author

@sebastianbergmann sebastianbergmann commented Jan 12, 2020

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

Loading

@foremtehan
Copy link

@foremtehan foremtehan commented Jan 12, 2020

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

Loading

@nezaboravi
Copy link

@nezaboravi nezaboravi commented Jan 26, 2020

Yes, fixed with latest PHPStorm update, not showing anymore

Loading

@safjanowski
Copy link

@safjanowski safjanowski commented Feb 29, 2020

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants