1

I'm trying to run some PhpUnit tests and it's working great but I keep running into the following problem. When I write a Unittest and it fails for whatever reason I'm getting the following error message (I'm also getting a unclear message why the test failed):

1) testUser_ReadOnly::testLoginFunction PHP Warning: require_once(../classes/PHP_Invoker.php): failed to open stream: No such file or directory in C:\xampp\htdocs\map\src\tests\autoload.php on line 6

Now I found a sollution on the internet that just says I have to add the following line to my composer.json: "phpunit/php-invoker": "1.1.*"

When I then try to run the composer update function I'm getting the following error messages:

  Problem 1
    - phpunit/php-invoker 1.1.4 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.3 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.2 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.1 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - Installation request for phpunit/php-invoker 1.1.* -> satisfiable by phpunit/php-invoker[1.1.1, 1.1.2, 1.1.3, 1.1.4].

Is there anybody who has a sollution for this problem? Any help is appreciated! Thanks in advance!

Frank W.
  • 777
  • 3
  • 14
  • 33
  • 1
    If you properly add composer to your composer config you shouldn't have to manually add extra dependencies just to run tests. – PeeHaa May 21 '16 at 18:40
  • Could you be a bit more specific please? – Frank W. May 21 '16 at 19:07
  • 1
    @FrankW. Revert the changes you did on the compser.json file, reset the system you have there (re-install in short) and then reduce your question to the minimum question you have. As you already have found out: Changing the composer.json did not solve your problem. So don't ask about it. More info: http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – hakre May 21 '16 at 21:49
  • I think you can solve your problem simply by fixing your "require_once" called, as explained here : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew May 22 '16 at 18:06

3 Answers3

2

Allright, I found the sollution to this problem. It was not clear for me when I started with phpUnit I had to run the commands from the Xampp shell instead of the windows commandline. You can find this by opening the Xampp control panel and click the 'shell button'. Since I execute the phpUnit commands here, I never had these problems again. So when you get the same errors as I posted in the question about, try to execute the PHPUnit commands within the Xampp shell.

Frank W.
  • 777
  • 3
  • 14
  • 33
0

The error message is indeed not very clear on first sight, but that already is the solution to the problem: Your setup is incompatible with PHPUnit, the autoloader you have configured in file C:\xampp\htdocs\map\src\tests\autoload.php brings the testsuite to halt.

As often with configuration problems they are hard to grasp until finally solved. Then they appear quite easy. Just inspect the file in question and fire-up the test-suite with a step-debugger (e.g. xdebug) placing a breakpoint at the line in question. You should be able to quickly find the culprit and most likely immediately spot the causing issue.

hakre
  • 193,403
  • 52
  • 435
  • 836
0

php-invoker requires the php pcntl extension. It seems that your php is not compiled with the pcntl extension enabled. You can check that by running php -m|grep pcntl. If you get pcntl, then it's enabled, but if you don't get anything, then it's not. In any case, pcntl is not available for windows as noted here, and from your paths, it looks like you're on windows.

Shadi
  • 9,742
  • 4
  • 43
  • 65