1

PHPUnit in PhpStorm. Everything working great, but why do I have this error?

enter image description here

The Framework shown in red, and the IDE error says:

Undefined namespace Framework.

How to get rid of it ?

9
  • Are you talking about Framework? Commented Oct 12, 2017 at 12:33
  • Yes, it is in red Commented Oct 12, 2017 at 12:34
  • Its not error. Are you getting any error in execution? Commented Oct 12, 2017 at 12:34
  • I got no execution errors, everything works... only the IDE is complaining Commented Oct 12, 2017 at 12:37
  • 2
    1) Based on screenshot -- please try File | Invalidate Caches... and restart IDE; 2) Do you have actually a PHPUnit (source files) in your project? It has to be either PHAR or Composer-installed version. 3) Have a look at this tutorials in case if you have not seen them yet: confluence.jetbrains.com/display/PhpStorm/… Commented Oct 12, 2017 at 13:14

2 Answers 2

1

Phpunit introduced the namespace PHPUnit\Framework\TestCase with Version 6, early 2017 (see https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-6.0.0).

Check your PhpStorm settings, probably you configured a version prior to 6.0.0, so PhpStorm doesn't know that namespace.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same error. using phpunit.phar file

I fixed adding the file as External library screenshot

I have several versions of phar so I just selected "exclude phar from project" in the other files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.