开发者

Phpunit behaves differently on different machines

I wrote a few PHPUnit tests for my PHP application. I am working on two development machines that synchronize the entire development filesystem, and there is an automatic testing system that runs the tests on a clean svn checkout.

Now, something weird is going on. One of the development machines runs Ubuntu linux 10.10, PHP 5.3.3, phpunit 3.4.6 which I later upgraded to 3.4.14. When I run phpunit on each single test, all tests pass. When I run phpunit on my xml configuration file that just runs them all, using phpunit --configuration=phpunit.cfg, the last test case fails, and a Class myClass not found error is returned. This class is inside a file that is loaded using require_once. Upgrading phpunit made no difference.

edit: I have the feeling that the list of files PHP includes using require_once is not reset on my linux box, but the classes are actually lost, that is, it thinks it has already included myclass.php while the class inside is not loaded.

Now, the other machine is running Mac OS X Snow Leopard 10.6.5, PHP 5.3.3 and phpunit 3.4.3. If I run the unit tests there individually, no errors occur, just as on the linux box, but when I run the tests using the xml configuration, no errors occur either. We also have an auto testing environment running linux 10.4 LTS, PHP 5.2.6 and phpunit 3.4.9. Also no errors.

All systems use exactly the same files, so there is no difference in the source code or tests. Also the phpunit.xml is the same.

I feel completely in the dark here. How can I figure out what the problem may be?

Both the linux development machine and the macbook ar开发者_如何学JAVAe running PHP 5.3.3. The autotest machine is runing 5.2.6


Two things to watch out for:

  • The include path in the PHP config on both machines
  • That there isn't another copy of the class file sitting around in your homedir or the cwd of the script. Usually . will be in the include path for PHP and rogue copies of files can cause problems like this


Is it possible that it isn't PHPUnit that is acting up, but a local php configuration issue causing problems in your system under test? Diff your php.ini on the 2 machines and you will likely find some differences.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜