TestingEnvironment

From PmaWiki
Jump to: navigation, search

This page will contain info on setting up a test environment.


Contents

[edit] Prerequisites.

  • PHP 5.2.7 (or later) but PHP 5.3.3 (or later) is highly recommended
  • Xdebug 2.0.5 (or later) but Xdebug 2.1.0 (or later) is highly recommended
  • PEAR Version: 1.9.1
  • PHP Unit 3.5 (or later)

[edit] Installing PHP Extensions

PHPUnit depends on package pear/XML_RPC2 that requires curl:

$ sudo apt-get install php5-curl

To run tests and calculate Code Coverage you need to install Xdebug:

  • Check if Xdebug installed and what version
$ dpkg -l | grep xdebug
  • Install
$ sudo apt-get install php5-xdebug

[edit] Upgrading PEAR

If you running latest Ubuntu 11.04 you probably have PEAR Version 1.9.1 But PHPUnit and phpunit/File_Iterator requires 1.9.2 to install. You can check PEAR version running next command:

$ pear version
PEAR Version: 1.9.1
PHP Version: 5.3.3-1ubuntu9.5
Zend Engine Version: 2.3.0

After that, if you have version less than 1.9 you need to update PEAR channel

$ sudo pear channel-update pear.php.net

And upgrade the PEAR

$ sudo pear upgrade-all

After upgrade checking the version again, and should be like this:

zarubin@ubuntu:~$ pear version
PEAR Version: 1.9.2
PHP Version: 5.3.5-1ubuntu7.2

[edit] Installing PHPUnit

PHPUnit should be installed using the PEAR Installer.

  • Discover necessary PEAR channels:
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear channel-discover components.ez.no
$ sudo pear channel-discover pear.symfony.com
  • Install PHPUnit with all dependencies
$ sudo pear install -a phpunit/PHPUnit

[edit] Known issues

If you tried to install PHPUnit before you upgrade PEAR some packages may be corrupted. And you probably will see errors like this (PHP_CodeCoverage was dependent of File_Iterator which was dependent of new PEAR installer):

$ phpunit --version
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

You will need to fix broken packages;

$ sudo pear install -a phpunit/PHP_CodeCoverage

You can also refer to the PHPUnit documentation http://www.phpunit.de/manual/current/en/installation.html

[edit] Installing Selenuim

  • Download a distribution archive of Selenium Server
  • Unzip the distribution archive and copy selenium-server-standalone-2.9.0.jar (check the version suffix) to /usr/local/bin, for instance
  • Start the Selenium Server server by running java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar
    • This can be on a totally different computer, e.g. a machine that has a specific browser available.
  • Install the PHPUnit_Selenium package, necessary for natively accessing the Selenium Server from PHPUnit:
pear install phpunit/PHPUnit_Selenium

[edit] Running phpMyAdmin Tests

If you successfully configured your testing environment, you can start running the phpMyAdmin Test Suite. All the tests are in the test/ folder

  • You can run test from command line specifying the configuration file.
$ cd $PHPMYADMIN_SOURCES
$ phpunit -c phpunit.xml.nocoverage
  • If you are also interested in the code coverage report, run this command. It will take much longer and will use quite a lot memory :
$ phpunit -c phpunit.xml.dist

Currently Unit Tests under heavy development. Details can be found on the UnitTesting page.

Personal tools