Skip to content
William Desportes edited this page Oct 29, 2022 · 10 revisions

Feel free to elaborate.

phpMyAdmin has two types of unit tests build on PHPUnit:

  • Classic unit tests
  • Browser scenarios (run via Selenium RC, introduced in phpMyAdmin 3.3)

Some additional information is available in the phpMyAdmin file test/README.rst.

PHP Unit

Setup

See: TestingEnvironment

Configuration files

test/bootstrap-dist.php

This file runs before starting test and contain all general code that should run before tests. You generally don't need to touch it as it does all global setup needed to run testsuite.

phpunit.xml

phpUnit configuration located in file phpunit.xml.dist. In this file located all configuration related for automated testing

  • Organization of TestSuites
  • Selenium browsers configuration
  • Type of logging that phpUnit needs to create
  • php.ini settings, constants and globals variables

More detailed information could be found in PHPUnit official documentation.

Running tests

You can run PHPUnit test from command line for whole suite.

$ cd <pma_dir>
$ ./vendor/bin/phpunit --no-coverage

PHPUnit 9.1.4 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.6 with Xdebug 2.9.5
Configuration: /mnt/Dev/@phpmyadmin/theREALphpMyAdminREPO/phpunit.xml

.............................................................   61 / 2440 (  2%)
.............................................................  122 / 2440 (  5%)
.............................................................  183 / 2440 (  7%)
...............WW............................................  244 / 2440 ( 10%)
.............................................................  305 / 2440 ( 12%)
.............................................................  366 / 2440 ( 15%)
.............................................................  427 / 2440 ( 17%)
.............................................................  488 / 2440 ( 20%)
.............................................................  549 / 2440 ( 22%)
.............................................................  610 / 2440 ( 25%)
.............................................................  671 / 2440 ( 27%)
..........................................S..................  732 / 2440 ( 30%)
.............................................................  793 / 2440 ( 32%)
.................................W...........................  854 / 2440 ( 35%)
.............................................................  915 / 2440 ( 37%)
.............................................................  976 / 2440 ( 40%)
............................................................. 1037 / 2440 ( 42%)
............................................................. 1098 / 2440 ( 45%)
............................................................. 1159 / 2440 ( 47%)
............................................................. 1220 / 2440 ( 50%)
............................................................. 1281 / 2440 ( 52%)
............................................................. 1342 / 2440 ( 55%)
............................................................. 1403 / 2440 ( 57%)
............................................................. 1464 / 2440 ( 60%)
............................................................. 1525 / 2440 ( 62%)
............................................................. 1586 / 2440 ( 65%)
............................................................. 1647 / 2440 ( 67%)
............................................................. 1708 / 2440 ( 70%)
............................................................. 1769 / 2440 ( 72%)
............................................................. 1830 / 2440 ( 75%)
............................................................. 1891 / 2440 ( 77%)
............................................................. 1952 / 2440 ( 80%)
............................................................. 2013 / 2440 ( 82%)
............................................................. 2074 / 2440 ( 85%)
............................................................. 2135 / 2440 ( 87%)
............................................................. 2196 / 2440 ( 90%)
............................................................. 2257 / 2440 ( 92%)
............................................................. 2318 / 2440 ( 95%)
............................................................. 2379 / 2440 ( 97%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 2440 / 2440 (100%)


Time: 00:10.703, Memory: 176.50 MB

You can also exclude some tests groups, for example:

# Do not run selenium tests
./vendor/bin/phpunit --no-coverage --exclude-group selenium
# Do not run tests which need network
./vendor/bin/phpunit --no-coverage --exclude-group network

# List all available groups
./vendor/bin/phpunit --no-coverage --list-groups

You can filter specific test to run:

./vendor/bin/phpunit --no-coverage --filter URL

Test Class structure

The following class hierarchy is used:

  • PHPUnit\Framework\TestCase
    • PhpMyAdmin\Tests\Selenium\TestBase
      • test cases ...
    • PhpMyAdmin\Tests\AbstractTestCase
      • test cases ...
Clone this wiki locally