5
votes

PHPUnit works greate for other projects but when I'm trying to run Yii tests I'm getting the following warning (even for empty tests):

There was 1 failure:

1) Warning

Warning: include(PHP_Invoker.php): failed to open stream: No such file or directory in C:\Users\pumpkin\Documents\GitHub\arhano\codebase\arhanoii\vendor\yiisoft\yii\framework\YiiBase.php on line 423

Warning: include(): Failed opening 'PHP_Invoker.php' for inclusion (include_path='.;C:\Users\pumpkin\Documents\GitHub\arhano\codebase\arhanoii\componen ts;C:\Users\pumpkin\Documents\GitHub\arhano\codebase\arhanoii\models;C:\xampp\php\PEAR') in C:\Users\pumpkin\Documents\GitHub\arhano\codebase\arhanoii\ vendor\yiisoft\yii\framework\YiiBase.php on line 423

Looks like I have to install phpunit/PHP_Invoker, but it's impossible, because it requires pcntl PHP extension, wich is not avilabe on Win.

Do you know how to mute this warning? Is it possible to run Yii tests on Windows without usage of PHP_Invoker?

5

5 Answers

8
votes

Here is a solution that worked for me: https://github.com/yiisoft/yii/issues/1907#issuecomment-14519537

Quote:

  • went to pear.phpunit.de
  • manually downloaded PHP_Invoker utility class
  • unzipped the file on my daughter's mac (I'm running Windows)
  • put the "Invoker" directory under C:\xampp\php\pear\PHP
  • put the "Invoker.php" file under C:\xampp\php\pear\PHP

I'm on a Windows 7 machine, the unzipping worked fine. Didn't need a mac...

The tests run fine in any case, but now I don't get the annoying long "include(PHP_Invoker.php): failed to open stream" message everytime an error occures during a test.

1
votes

Following this tutorial with a small tweak worked for us.

It basically clones in the Invoker repo. I assume Invoker still won't work, but it stops PHPUnit from erroring:

{
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.phundament.com"
        },
        {
            "type": "package",
            "package": {
                "name": "phpunit/php-invoker",
                "version": "1.1.3",
                "source": {
                    "type": "git",
                    "url": "http://github.com/sebastianbergmann/php-invoker",
                    "reference": "master"
                },
                "autoload": {
                    "classmap": [
                        "src/"
                    ]
                }
            }
        }
    ],
    "require-dev": {
        "phpunit/phpunit": "4.1.*",
        "phpunit/phpunit-selenium": "*",
        "phpunit/phpunit-skeleton-generator": "*",
        "phpunit/dbunit": "*",
        "phpunit/phpunit-story": "*",
        "phpunit/php-invoker": "*",
        "phpunit/phpunit-mock-objects": "*"
    }
} 
0
votes

The file is (PSR-0 compatible) PHP/Invoker.php, so you need to change the YiiBase.php and replace the _ with / there.

0
votes

@cweiske : That line is actually used by PHPUnit's autoload(), and therefore could not be changed.

@Alex : I have the same problem here, the reason is that PHPUnit's PHP_Invoker does not work with Windows, because it depends on an extension named "pcntl" that only works on UNIX systems. Since the problem comes from a third-party framework running on Windows, I believe Sebastian Bergmann won't care much about the issue : https://github.com/sebastianbergmann/php-invoker/issues/6

Anyway, the tests seem to run fine. So...

0
votes

A phpunit installation guide that worked for me (Windows 7, XAMPP): http://learnyii.blogspot.com/2011/08/how-to-install-phpunit-on-windows.html

in command promp (as admin):

pear channel-update pear.php.net  
pear upgrade-all  
pear channel-discover pear.phpunit.de  
pear channel-discover components.ez.no  
pear channel-discover pear.symfony-project.com  
pear update-channels  
pear install -a -f phpunit/PHPUnit

P.S.
IF you get errors for PHPUnit_Extensions_Selenium_TestCase use:

pear install phpunit/PHPUnit_Selenium

If you get errors for PHPUnit_Extensions_Story_TestCase use:

pear install phpunit/PHPUnit_Story