Problem to setup PHPUnit

Answered

My PhpStorm was working perfectly, a couple of days ago, but not anymore. In the meantime, I updated to the latest version of PHPStorm (and may have also messed with some settings). I still can run my tests from the command line, with the plain old 'phpunit' command, which relies on my 'phpunit.xml.dist'.

The application is a Symfony2 app and the tests are currently failing by not finding some of the Doctrine annotations, like the one below:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class MyOrg\SomeBundle\Entity\Node does not exist, or could not be auto-loaded.

I tried to delete my .idea folder and reimport the project, but that didn't work as well.

Notes:

1 - My PHPUnit is configured to use Composer autoloader (from vendor/autoload.php)
2 - The Test Runner is using my phpunit.xml.dist as 'Default configuration file'
3 - The Test Runner is not using any 'Default bootstrap file', since the phpunit.xml.dist already points to the same vendor/autoload.php

What is the 'failproof' recommended way to set it up?

0
3 comments

What's your exact PHPUnit and PhpStorm versions?

If you check the MyOrg\SomeBundle\Entity\Node class - would  "@Doctrine\ORM\Mapping\Entity" be resolved correctly there?

0

PhpStorm 2016.3.3
Build #PS-163.13906.21, built on March 8, 2017
Licensed to ---- / Thiago Lima
You have a perpetual fallback license for this version
Subscription is active until January 27, 2018
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Here is a chunk of my composer.json:

{
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*",
},
"require-dev": {
"phpunit/phpunit": "~4.1",
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
}
}

And yes: that class was resolving correctly.

I the meanwhile, I tried a lot of things and managed to fix it. Don't know exactly what fixed it, though.

0

Ok... Now the tests are failing again, for that and other annotations, like the one bellow:

[Semantical Error] The annotation \"@Symfony\\Component\\Validator\\Constraints\\IsTrue\"in method MyOrg\SomeBundle\Entity\OtherEntity::passesSomeValidation() does not exist, or could not be auto-loaded."
0

Please sign in to leave a comment.