-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
TestingEnvironment
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
-
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
For the end-to-end testing, phpMyAdmin uses 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>
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
Jest is the tool that phpMyAdmin uses to test the JavaScript files. You can run it with the following command:
yarn run test
Popular destinations:
- Team meetings
- GSoC home
- Developer guidelines
- How to install on Debian and Ubuntu
- Issue and pull-request management
User resources: