Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse and PHPUnit: "The import PHPUnit\Framework\TestCase cannot be resolved"

I'm starting with PHPUnit, and it works fine so far. I just got one problem: Eclipse (Oxygen.3) is telling me in this line:

use PHPUnit\Framework\TestCase;

"The import PHPUnit\Framework\TestCase cannot be resolved"

I went to Window -> Preferences -> PHP -> Tools -> PHPUnit and added the path to my phpunit.phar. But this didn't help.

I went to Window -> Preferences -> PHP -> Source Paths -> Libraries and tried to import my phpunit.phar. But this results in an error "The selected file is not a valid user library data file".

Any other ideas how to get rid of this error?

like image 263
Werner Avatar asked Apr 03 '18 07:04

Werner


1 Answers

I was having the same problem and this solution worked for me:

  1. Going into Project > Properties
  2. Under PHP > Include Path, pick the "Libraries" tab.
  3. On "Add External PHARs..." select the PHPUnit framework file on your system (phpunit.phar).
like image 161
Flavio Aparecido Ribeiro Avatar answered Oct 19 '22 23:10

Flavio Aparecido Ribeiro