Download the PHP package luyadev/luya-testsuite without Composer
On this page you can find all versions of the php package luyadev/luya-testsuite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download luyadev/luya-testsuite
More information about luyadev/luya-testsuite
Files in luyadev/luya-testsuite
Package luya-testsuite
Short Description TestCases and Data for LUYA Modules and Components. Makes testing less pain.
License MIT
Homepage https://luya.io
Informations about the package luya-testsuite
LUYA Test Suite
Providing PHPUnit Testcases and a built in Webserver to test your Application, Modules, Components, APIs or Classes.
Whats included?
Test Cases
- Web application test case
- Console application test case
- Server (for APIs) test case
- CMS Block test case
- NgRest test case (for model, controller and API)
Traits
- Message file compare trait
- Migration file check trait
Fixtures
- ActiveRecord fixture creates the table on loading based from array or rule definition.
See the full Documentation
Install
Add the luyadev/luya-testsuite
package to the require-dev section of your composer.json file:
Create a new folder tests
inside your appliation folder and create a test classes:
To run the unit tests while (assuming your tests are in directory tests/
) run in your terminal:
In order to support sqlite fixtures install:
Example Test Cases
Some example in how to use the LUYA Testsuite for different scenarios.
Testing API and Application
When working with APIs or Customer Websites somtimes you just want to test the Website itself, what is the response, does all the pages still work after my update? Therefore we have luya\testsuite\cases\ServerTestCase
.
This example will run your LUYA application within a PHP Webserver and test the response status codes or contents for a set of given pages. In order to run this example create a MyWebsiteTest.php
file inside the tests
folder.
As the Webserver process may run from a different permission level you have to ensure the assets/runtime folder has the required permissions.
Controller Function Test
We're using getMockBuilder()
as shown in the multiple examples in the PHPUnit to setup the DefaultController and assert the registered module addressbook
. To test the the runtime exception (caused by a database error), we use the mock method
function: