Skip to content
Maurício Meneghini Fauth edited this page Nov 3, 2021 · 10 revisions
  1. About the tests
  2. PHP tests
  3. Selenium tests
    1. Configuring Selenium
    2. Running Selenium tests
  4. JavaScript tests

About the tests

All tests are located in the test directory, and it has the following structure:

  • test All testing related files
    • classes PHP unit tests
    • javascript JavaScript unit tests
    • selenium Selenium tests
    • test_data Files used by tests

PHP tests

PHPUnit is the tool that phpMyAdmin uses to run the tests written in PHP. To execute all tests, run the following command in your terminal:

vendor/bin/phpunit

To disable the code coverage report, run this command. It will be faster and will use less memory to execute the tests.

vendor/bin/phpunit --no-coverage

You can also run a single test file:

vendor/bin/phpunit --no-coverage test/classes/Dbal/DatabaseNameTest.php

Selenium tests

For the end-to-end testing, phpMyAdmin uses Selenium.

Configuring Selenium

If your browser is not natively in English, you should have to add this in config.inc.php:

$cfg['Lang'] = 'en';

Otherwise, tests that are looking for a specific English message will fail.

The following environment variables configure where testsuite connects:

  • TESTSUITE_USER

    Username to connect on the interface located at TESTSUITE_URL

  • TESTSUITE_PASSWORD

    Password to connect on the interface located at TESTSUITE_URL

  • TESTSUITE_DATABASE_PREFIX

    Database prefix to use for testing (Avoid database grouping characters like _).

  • TESTSUITE_URL

    URL where tested phpMyAdmin is available.

Additionally, you need to configure link to Selenium and browsers. You can either set up Selenium locally or use BrowserStack automated testing.

For local setup, define following:

  • TESTSUITE_SELENIUM_HOST

    Host where Selenium is running.

  • TESTSUITE_SELENIUM_PORT

    Port where to connect.

  • TESTSUITE_SELENIUM_BROWSER

    Browser to use for testing inside Selenium.

With BrowserStack, set following:

  • TESTSUITE_BROWSERSTACK_USER

    BrowserStack username.

  • TESTSUITE_BROWSERSTACK_KEY

    BrowserStack access key.

For example, you can use following setup in phpunit.xml:

<php>
    <env name="TESTSUITE_USER" value="selenium_user"/>
    <env name="TESTSUITE_PASSWORD" value="selenium_password"/>
    <env name="TESTSUITE_DATABASE_PREFIX" value="test"/>
    <env name="TESTSUITE_URL" value="http://localhost/phpmyadmin/" />
    <env name="TESTSUITE_SELENIUM_HOST" value="127.0.0.1" />
    <env name="TESTSUITE_SELENIUM_PORT" value="4444" />
</php>

Running Selenium tests

To be able to run the Selenium tests, you need to have webserver, database and Selenium running.

To start the Selenium Server, you should run the following in a dedicated terminal:

  • Selenium 3
    java -jar selenium-server-standalone-3.141.59.jar
    
  • Selenium 4
    java -jar selenium-server-4.0.0.jar standalone
    

After starting the Selenium Server, you can run the following command to execute all Selenium tests:

vendor/bin/phpunit --no-coverage --testsuite selenium

JavaScript tests

Jest is the tool that phpMyAdmin uses to test the JavaScript files. You can run it with the following command:

yarn run test
Clone this wiki locally