Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set up PHPunit to work with Yii on Windows

Tags:

php

phpunit

yii

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?

like image 509
Alex Avatar asked Dec 25 '12 15:12

Alex


2 Answers

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.

like image 111
c-cba Avatar answered Nov 09 '22 04:11

c-cba


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": "*"
    }
} 
like image 30
Arth Avatar answered Nov 09 '22 06:11

Arth