Flo Bayer
Flo Bayer

Reputation: 1260

PhpStorm: Class 'PhpUnit\Framework\TestCase' not found (composer / autoload)

I've got a problem with PhpStorm, composer and PHPUnit.

enter image description here

My test class extends the PhpUnit\Framework\TestCase class and when you run the test, the following happens:

enter image description here

First it seems like PhpStorm loads the old PHPUnit (3.7.21) from XAMPP's PHP and not the recognized PHPUnit (7.3.3) as setup in the PhpStorm settings / installed to the vendor folder.

But I don't think so.

I think PhpStorm tries to load the PhpUnit\Framework\TestCase class by the autoloader, but I don't know why it doesn't find the PHPUnit...

Thanks in advance!


The whole project could be minimized to this simple test class:

enter image description here

The composer.json looks like the following:

"autoload": {
  "psr-4": {
    "Flo\\Newsletter\\": "src/"
  }
},
"require": {
  "php": "^7.1"
},
"require-dev": {
  "phpunit/phpunit": "^7.3.3"
}

Upvotes: 2

Views: 1793

Answers (1)

Eugene Morozov
Eugene Morozov

Reputation: 3043

Namespaces are case-sensitive. Please change PhpUnit to PHPUnit in the import.

Although PhpStorm could really detect that. Here's a feature request for that: https://youtrack.jetbrains.com/issue/WI-38140

Upvotes: 3

Related Questions