PhpStorm + PHPUnit failures not displayed in Test Tab - symfony

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.

Related

Symfony PHPUnit Bridge: Get specific list of deprecation notices

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.

Codeception for WordPress: Command init not defined

I followed the steps here (http://codeception.com/for/wordpress) and successfully installed Codeception. But when I enter codecept init wpbrowser into the terminal to get started with Codeception for Wordpress, I get the error: Command init not defined. How can I correct this?
That's the correct command, but unfortunately, even the init command won't set everything up. It's very difficult to get CodeCeption to run the first time. At WordPress-BDD.com, we have a project going to get a WP dev server going with CodeCeption via one command. This will get WordPress CodeCeption going on a clean Ubuntu machine):
Setup WordPress CodeCeption in the cloud

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!

Integrate PHPUnit with PhpStorm got error

I'm trying to set up my project with PHPUnit. I tried to configure PHPUnit with my project on PhpStorm following steps explained on this article.
http://blog.jetbrains.com/webide/2013/03/phpunit-installation-via-composer-in-phpstorm/
But when I try to run tests I continuously getting following error.
Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in C:\Users\win 8\AppData\Local\Temp\ide-phpunit.php on line 49
Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.;C:\wamp\bin\php\php5.6.19\pear') in C:\Users\win 8\AppData\Local\Temp\ide-phpunit.php on line 49
Process finished with exit code 255
I tried setting up number of new projects and in all the cases I get this stupid error. I don't know how to fix this. Please, your help is highly appreciated.
It seems that you are using PHPUnit through your IDE, and that the IDE has not provided PHPUnit with the correct include path items.
To understand about include path, and what is happening in your problem, see this post, part on inclusions by relative or absolute path and the include path.
To solve your problem, you will need to change a setting in your IDE, either to include the PHPUnit library in the general include path of running PHP, or in the include path of running PHPUnit.
It was version mis-match. I tried to integrate PHPUnit 5.3+ with PHPstorm 8.+ version. When I try PHPUnit 5.3+ with PHPStorm 2016.1 it worked as a charm.

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