Loading...
 

OctoberCMS Unit Testing

Resources

Testing plugins

“Then, a tests/ directory can be created to contain the test classes. The file structure should mimic the base directory with classes having a Test suffix. Using a namespace for the class is also recommended.”

$ php ../../../vendor/phpunit/phpunit/phpunit


Changing the database engine for plugins tests

By default, OctoberCMS uses SQLite stored in memory for the plugin testing environment. If you want to override the default behavior set the useConfigForTesting config to true in your /config/database.php file. When the APP_ENV is testing and the useConfigForTesting is true database parameters will be taken from /config/database.php.

You can override the /config/database.php file by creating /config/testing/database.php. In this case, variables from the latter file will be taken.

System testing

Unit tests can be performed by running phpunit in the root directory or inside /tests/unit.

$ php vendor/phpunit/phpunit/phpunit


Last edited by MichaelAlber .
Page last modified on Sunday March 22, 2020 04:45:02 UTC.