Quirks of PHPUnit & Xdebug setup in Ubuntu 9.10 (Karmic Koala)

July 7, 2010 at 4:25 am 2 comments

PHPUnit is a good Unit Testing framework for PHP and works well with the Zend framework.

Setup Quirks for PHPUnit & Xdebug

It is especially easy (installing & configuring via PEAR – PHP equivalent of CPAN for Perl) [thank you Sebastian for the update]:

>sudo apt-get install php-pear
>sudo pear upgrade-all PEAR
>sudo pear channel-update PEAR
>sudo pear channel-discover pear.phpunit.de
>sudo pear install pear.phpunit.de/phpunit

Install the xdebug libraries as well:

>sudo apt-get install php5-dev
>sudo pecl install xdebug

Edit the file /etc/php5/apache2/php.ini and add the following two lines to the bottom of the file:

[xdebug]
zend_extension="/usr/lib/php5/20060613+lfs/xdebug.so"

(Note that the xdebug.so file might be located in a different directory. Please double check this).

PHPUnit Code Coverage Memory Quirk

Another quirk is a memory hog issue that exists with the code coverage reporting done by PHPUnit.

As PHPUnit is run from the command line, you will need to modify the ‘cli’version of the php.ini file than rather apache2 directory version.

> vim /etc/php5/cli/php.ini

And look for the memory_limit variable and set it to 512 Mb (Yes, it does take a lot memory!!).

>memory_limit = 512 M

This is recommended by Jeffrey Sambells

PHPUnit erroneous package Quirk

It appears that PHPUnit uses YUI for the javascript even though t is disabled in /usr/share/PHPUnit/TextUI/TestRunner.php ($arguments['reportYUI'] = FALSE;)

The error message being reported is the same as reported on Ubuntu launchpad:

# phpunit --coverage-html coverage-html application
 PHPUnit 3.3.16 by Sebastian Bergmann.
Time: 0 seconds
OK (0 tests, 0 assertions)
Generating code coverage report, this may take a moment.
 Warning: copy(/usr/share/php/PHPUnit/Util/Report/Template/container-min.js): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Util/Report.php on line 242
Call Stack:
 0.0008      95544   1. {main}() /usr/bin/phpunit:0
 0.4147    6243128   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
 5.0970    6249232   3. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:128
 5.0979    6263480   4. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:424
 5.0989    6268848   5. PHPUnit_Util_Report::copyFiles() /usr/share/php/PHPUnit/Util/Report.php:115
 5.1511    6272616   6. copy() /usr/share/php/PHPUnit/Util/Report.php:242
Warning: copy(/usr/share/php/PHPUnit/Util/Report/Template/yahoo-dom-event.js): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Util/Report.php on line 242
Call Stack:
 0.0008      95544   1. {main}() /usr/bin/phpunit:0
 0.4147    6243128   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
 5.0970    6249232   3. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:128
 5.0979    6263480   4. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:424
 5.0989    6268848   5. PHPUnit_Util_Report::copyFiles() /usr/share/php/PHPUnit/Util/Report.php:115
 5.1743    6272616   6. copy() /usr/share/php/PHPUnit/Util/Report.php:242"

The fix for this is relatively straightforward, though having an updated package should alleviate this. Doing a bit of googling showed there is a patch. Looking at the patch it was a simple case of editing /usr/share/php/PHPUnit/Util/Report.php and removing the offending javascript lines from the php script:

-- /usr/share/php/PHPUnit/PHPUnit/Util/Report.php
+++ /usr/share/php/PHPUnit/PHPUnit/Util/Report.php
@@ -230,12 +230,10 @@
 'chameleon.png',
 'close12_1.gif',
 'container.css',
-          'container-min.js',
 'glass.png',
 'scarlet_red.png',
 'snow.png',
 'style.css',
-          'yahoo-dom-event.js'
 );

Hope this helps whoever comes across the same quirks when setting up PHPUnit.

Advertisement

Entry filed under: Uncategorized. Tags: .

Python – 2 legged OAuth Woes How not to display fault exception messages

2 Comments Add your own

  • 1. Sebastian Bergmann  |  July 7, 2010 at 6:52 am

    As the manual of PHPUnit clearly states, the only supported (by me, at least) way of installing PHPUnit is using the PEAR Installer.

    Reply
    • 2. debounce  |  July 7, 2010 at 1:41 pm

      Thanks Sebastian, I made the changes based on your comments.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


QR Code

Flickr Photos

IMG_1619

IMG_1618

IMG_1617

More Photos

Follow

Get every new post delivered to your Inbox.