Symfony PHPUnit Bridge: Get specific list of deprecation notices - symfony

Running PHPUnit with the Symfony PHPUnit Bridge listener gives me a yellow box "Legacy deprecation notices (10)" in a custom Drupal 8 module. I would like to fix those 10, but am struggling to get the details which they are (e.g. which line of code).
I've read the documentation on the Symfony PHPUnit Bridge.
I've added --verbose to the phpunit command line.
I've set the SYMFONY_DEPRECATIONS_HELPER environment variable to 0 or 1, both in Bash and in my phpunit.xml.
I have the suspicion that something in my environment reverts my attempts to see details. Nothing seems to change the output.
Versions:
- PHPUnit 4.8.36
- Symfony PHPUnit Bridge 3.2.14
- PHP 7.0.22
Thanks in advance!

If you want more detail, you can try this:
export SYMFONY_DEPRECATIONS_HELPER="/.*/"
before launch phpunit.

Related

PhpStorm + PHPUnit failures not displayed in Test Tab

I want to run tests in my applications in PhpStorm. Application is running on Symfony, for tests I am using PHPUnit and Symfony PHPUnit bridge.
Tests are running, but PhpStorm does not display any failure - it says: "All tests passed". In raw output is log of failure, so test failed (see screenshot), but PhpStorm did not show it.
Can anyone help me please?
Please follow the issue, Sebastian has changed line endings so we'll have to update our parser.
https://youtrack.jetbrains.com/issue/WI-42390
https://github.com/sebastianbergmann/phpunit/commit/56de7e9f96869a808fefc5a2fefbca7970ad2aab
I am using newest version of PHPStorm. I tried to downgrade from PHPUnit 7^ to PHPUnit 6^, after that downgrade it works perfectly. So I found temorary fix for this.

Fail to create a controller file with make command in Symfony

I'm learning Symfony now and I ran into a problem trying to create a controller file with the make command. The path of the project is "E:\web_dev\testproject". When I ran the command
php bin/console make:controller
and then entered the name of the controller, it returns an error "Failed to create "E:\web_dev\testproject//E:\web_dev\testproject\vendor\composer/../../src/Controller"". What is the problem?
I have the same problem.
I have found this Thread and it seems that the problem is in the Maker Bundle. After running "composer remove maker" and "composer require maker 1.0.2" it works by me.
In the other Thread they used Maker Version 1.0.0 but in Symfony4 the generated AbstactController do not Functionaly so I use Version 1.0.2.
Hope it help you.

PhpStorm: error executing Behat tests No specifications found at path(s) but works from command line

I'm using PhpStorm and Vagrant to develop a Symfony project.
I configured PhpStorm to execute Behat tests with the Vagrant machine but when I try to run or debug them I got this error:
vagrant:///Users/jose/Documents/WWW/symfony_project/usr/bin/php /home/vagrant/.phpstorm_helpers/behat.php --format PhpStormBehatFormatter --config /var/www/symfony/behat.yml /var/www/symfony/features/api/brand/full_rest.feature:13
Testing started at 10:48 ...
0 scenario0 step0m0.05s (14.76Mb)
[Behat\Testwork\Tester\Exception\WrongPathsException]
No specifications found at path(s) `/var/www/symfony/features/api/brand/full_rest.feature:13`. This might be because of incorrect paths configuration in your `suites`.
Although if I execute it from the command line inside the Vagrant machine it works OK:
./vendor/bin/behat --config /var/www/symfony/behat.yml /var/www/symfony/features/api/brand/full_rest.feature:13
#brands #api
Feature: API to manage the brands
As a frontend app
.......
I've configured the PHP Interpreter with my Vagrant VM and I also think the Behat configuration is set OK: I see the Behat version, I've set the behat config path... I don't understand why the execution from PhpStorm fails.
Any ideas? Thanks in advance
This a bug in behat 3.4.0 breaks the ability to run individual tests
Try to switch back to "behat/behat": "3.3.1".

Running PHPUnit test in PhpStorm adds "--teamcity" option causing error

I have the latest PhpStorm (2016.2) and PHPUnit phar (5.5.4). For some reason when I run a PHPUnit test in my project in PhpStorm, it is adding on --teamcity to the run command, resulting in a failure:
Testing started at 12:52 PM ...
Unit test suite invoked with a path to a non-unit test: --teamcity
Process finished with exit code 1
I have no idea where this --teamcity option is coming from, it happens no matter what test I run, and even when starting from a blank configuration. I also do NOT have the TeamCity plugin installed, I don't even use TeamCity.
Here's what the full command appears as:
/usr/local/Cellar/php70/7.0.9/bin/php /Users/name/bin/phpunit-5.5.4.phar --configuration /path/to/config/my-phpunit.xml ClassNameTest /Users/name/PhpstormProjects/path/to/tests/unit/app/ClassNameTest.php --teamcity
(sensitive information swapped out)
All I want to do is get rid of this --teamcity option, everything works if I run in a separate terminal window without that option. This only recently started happening, maybe after a PhpStorm update.
tl;dr
I only could resolve this by removing the system installed phpunit instance from my system (Linux):
sudo apt remove phpunit-*
Details
Even if the setting in PhpStorm was to use composer autoloader:
for some reason it ended up using TeamCity from /usr/share/php/PHPUnit/Util/Log/TeamCity.php:
Project's local PHPUnit was 6.2 while the system default was 5.1 -> they're incompatible.
I spent half a day struggling with this. The underlying issue is switching between PHPUnit versions (6.x.x -> 4.x.x). (Happened to me by switching branches)
A click on the refresh button in the PHPUnit preferences fixes it.
(Languages & Frameworks > PHP > PHPUnit)
Make sure the version of PHPUnit it thinks you have matches the one it reports.
This --teamcity option is used by PHPStorm to output tests result.
What you're facing is an issue caused by PHP7 and an old version of PHPUnit.
Remove your PHPUnit 5 and install the latest one (currently 6.2) with composer and use PHPUnit namespaces instead.
More info on this bug: https://github.com/sebastianbergmann/phpunit/issues/2460
Problem was internal to the project. PHPUnit does not contain that error message. Sorry!

Running phpunit to test composer plugin vfsStream

Using PHPStorm on a project with Composer and PHPUnit (all of which have already work correctly) how do I run PHPUnit test on a composer plugin inside "vendor" in this case mikey179/vfsStream?
My project structure looks like this:
myscripts/
vendor/
- mikey179
- vfsStream
composer.json
I want to run PHPUnit to test vfsStream plugin.
I was able to run Testing on my own test code (outside vendor directory).
When I run PHPUnit test (That little green play button on top) I got the following:
usr/bin/php /tmp/ide-phpunit.php --bootstrap /path/to/project/vendor/autoload.php --configuration /path/to/project/vendor/mikey179/vfsStream/phpunit.xml.dist /path/to/project/vendor/mikey179/vfsStream
Testing started at 5:53 PM ...
PHPUnit 3.8-g8d770d8 by Sebastian Bergmann.
Configuration read from /path/to/project/vendor/mikey179/vfsStream/phpunit.xml.dist
Time: 2.22 seconds, Memory: 2.25Mb
No tests executed!
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /path/to/project/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML.php on line 127
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main() /tmp/ide-phpunit.php:506
PHP 3. PHPUnit_TextUI_Command->run() /tmp/ide-phpunit.php:268
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /path/to/project/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:173
PHP 5. PHP_CodeCoverage_Report_HTML->process() /path/to/project/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:465
PHP 6. date() /path/to/project/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML.php:127
Generating code coverage report in HTML format ... done
Process finished with exit code 0
From what I see it's an issue with PhpStorm's helper/wrapper script (/tmp/ide-phpunit.php), which is used for integration purposes (track tests progress in real time -- messages must be formatted in specific way; etc).
Test files do not have standard and expected Test.php ending -- instead they have custom TestCase.php .. and helper script seems to be unable to apply that config option from phpunit.xml.dist file correctly (it will search for *Test.php files only).
If you rename all *TestCase.php file to be *Test.php it will start working in PhpStorm (I've renamed just a few .. and they got detected and executed just fine).
Right now I may only suggest to either rename test files as described above (which is not a good idea in long run if you plan to run those tests on regular basis and keep downloading latest sources of that library) or submit a bug ticket to PhpStorm Issue Tracker explaining the situation: http://youtrack.jetbrains.com/issues/WI and hopefully devs will fix it soon.
You don't run a test on a package in vendor/. You clone the repo and follow the instructions they've given in the testing documentation. In the case of mikey179/vfsStream, there's a github repo: https://github.com/bovigo/vfsStream and it even has a .travis.yml file you can read for inspiration: https://github.com/bovigo/vfsStream/blob/master/.travis.yml
If you're concerned that you've got a version of vfsstream that doesn't pass tests, then you can look at the version that's installed in your project with composer show mikey179/vfsStream and then check out that tag in the repo before running the tests.
The reason is that the package might very well have different dev dependencies than your project, so no matter what else you do you'll end up with broken test runs. Composer ignores dev dependencies for packages other than the main project.

Resources