Unit Test
Unit testing is an integral part of LUYA. Every new class and function should be accompanied by a dedicated unit test. We recommend you to use LUYA Testsuite
Unit test a single class
- Create the test for your class in
tests/within the appropriate folder (for exampleInflectorHelperTest.phpintests/core/helpers). For a general guide to create PHP Unit Tests refer to Getting Started with PHPUnit or the Official Documentation. - Make sure your Composer packages are updated by running
composer installwithin the local LUYA dev package. - Run the tests for your class by executing
./vendor/bin/phpunit tests/core/helpers/InflectorHelperTest.php(if you want to test to theInflectorHelperTest.phpfor example)
Unit test everything with a complete suite test
- Create a new database (for example luya_env_phpunit).
- Insert the database dump for your LUYA version from
tests/data/sql/(for example1.0.0.sql). - Rename
phpunit.xml.distin LUYA root tophpunit.xml. - Change dsn, username and password in
phpunit.xml. - Ensure you have installed the current Composer packages by running
composer installwithin the local LUYA dev package. - Execute the phpunit binary file with
./vendor/bin/phpunit.
