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

For running Selenuim tests you need to setup Testing_Selenium package and run Selenium server. Selenium server requires Java.

  • Install Testing_Selenium with preferred state alpha
$ sudo pear install Testing_Selenium-alpha
$ java -jar selenium-server-standalone-2.0b3.jar 

By default Selenium Server listens on port 4444. You can also specify the port for Selenium Server to listen.

$ java -jar selenium-server-standalone-2.0b3.jar -port 4455
11:02:31.877 INFO - Java: Sun Microsystems Inc. 19.1-b02
11:02:31.878 INFO - OS: Linux 2.6.38-9-generic amd64
11:02:31.883 INFO - v2.0 [b3], with Core v2.0 [b3]
11:02:31.968 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4455/wd/hub
11:02:31.968 INFO - Version Jetty/5.1.x
11:02:31.969 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:02:31.970 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:02:31.970 INFO - Started HttpContext[/,/]
11:02:31.983 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@2f3adc56
11:02:31.983 INFO - Started HttpContext[/wd,/wd]
11:02:31.986 INFO - Started SocketListener on 0.0.0.0:4455
11:02:31.986 INFO - Started org.openqa.jetty.jetty.Server@2e0ece65

That means the Selenium Server is successfully started and listening 4455 port.

[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.

sponsors