Showing posts with label phpunit. Show all posts
Showing posts with label phpunit. Show all posts

Wednesday, 11 April 2012

Pear and phpunit

Update PEAR to the latest PHPUnit version


    sudo pear upgrade PEAR
    sudo pear config-set auto_discover 1
    sudo pear install pear.phpunit.de/PHPUnit


from http://stackoverflow.com/questions/1528717/phpunit-require-once-error the files are installed to

/usr/share/php

which should contain

assure@snapdragonubuntu:/usr/share/php$ ls -al PHPUnit/
drwxr-xr-x  7 root root  4096 2012-01-17 14:28 .
-rw-r--r--  1 root root 13302 2012-01-17 14:28 Autoload.php
drwxr-xr-x  4 root root  4096 2012-01-17 14:28 Extensions
drwxr-xr-x  9 root root  4096 2012-01-17 14:28 Framework
drwxr-xr-x  2 root root  4096 2012-01-17 14:28 Runner
drwxr-xr-x  2 root root  4096 2012-01-17 14:28 TextUI
drwxr-xr-x  7 root root  4096 2012-01-17 14:28 Util


The versions can be verified by

pear list -c phpunit
Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
File_Iterator      1.3.1   stable
PHPUnit            3.6.7   stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.2   stable
PHP_Invoker        1.0.1   stable
PHP_Timer          1.0.2   stable
PHP_TokenStream    1.1.3   stable
Text_Template      1.1.1   stable


Ensure the php.ini files have this path on the include path

    /etc/php5/apache2/php.ini
    /etc/php5/cli/php.ini

should both include the PEAR php share libraries

    ; UNIX: "/path1:/path2"
    include_path = ".:/usr/share/php"


Tuesday, 17 January 2012

phpunit and PEAR

Back on the php unit tsting buzz today but when i ran 'phpunit' is got this

    assure@snapdragonubuntu:~/bhaa/zend/trunk$ phpunit PHP Warning:   require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38 PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38 

The first solution is to include the php code coverage tool

http://stackoverflow.com/questions/1528717/phpunit-require-once-error 

Once installed, try again but

assure@snapdragonubuntu:~$ phpunit --help PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39

It seems that the version of phpunit was fairly old so i followed

http://superuser.com/questions/55055/how-to-install-an-updated-version-of-pear-phpunit-on-ubuntu

and updated PEAR and phpunit

assure@snapdragonubuntu:~$ pear list -c phpunit
Installed packages, channel pear.phpunit.de: ============================================ Package Version State File_Iterator 1.3.1 stable PHPUnit 3.6.7 stable PHPUnit_MockObject 1.1.0 stable PHP_CodeCoverage 1.1.1 stable PHP_Invoker 1.0.1 stable PHP_Timer 1.0.2 stable PHP_TokenStream 1.1.2 stable

I also added the phpunit to the include_php in my php.ini file