PhpStorm has some sort of weird behaviour that is driving me crazy. I've got my project setup to have a source
and a test
directory. The source
directory should be for productive code, while the test
directory should contain all the phpunit tests.
In those directories, the folder structure is mirrored - if I have a class \foo\Bar
,
then there is
src/foo/Bar.php
and test/foo/BarTest.php
.
I've marked src/
and test/
as source and test directory in PhpStorm, however, every time I want to create a new test suite for a class, PhpStorm defaults to put the test class into the src/
directory next to the class under test.
It's possible to change that, however it get's more annoying when that same directory in test/
does not exist yet. Instead of creating it, PhpStorm will just reject to create that test suite for me.
Maybe I am misunderstanding the concept behind test management in PhpStorm quite a bit - because it just can't be that bad user experience.
Is there something I am doing wrong, or something that I can configure to make the situation less painful?
You are doing nothing wrong. It just does not work this way -- devs coded it to behave in a way it is right now.
Originally IDE used PHPUnit's ability to generate test classes (back then such functionality was part of actual PHPUnit). Then PHPUnit creator(s) have moved this functionality into separate package (phpunit-skelgen
) .. and you had to install it manually/separately. Then devs decided to drop phpunit-skelgen support completely and implemented current implementation (which is also more in line with similar routines in other IDEs built on IDEA platform/technologies supported by those IDEs).
There are quite few tickets about changing such behaviour to the same as you described/desired .. but so far it does not look like it's in their priority list...
Subscribe to those tickets (star/vote/comment) to get notified on progress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With