Since translate5 has a service oriented architecture (SOA) with a REST API a test framework is provided to test against the API.
The test framework is located in:
application/modules/editor/testcases/
Configuration
Since the REST interface is tested, the URL for the API has to be configured before test can be run.
Create therefore an "apitest.conf" file in the framework directory.
A sample file "apitest.conf.sample" is provided, and can be copied to get a basic config file.
# # Please change the following values to your needs # #the root directory of the translate5 installation to test APPLICATION_ROOT=/mnt/mittagqi/www/www.translate5.net/ #the directory of zend (needed explicit) ZEND=/var/www/zend/ # the API URL of the installation to test (including rundir and trailing slash!) API_URL="http://translate5.localdev/" # the data task data directory as configured in the application config, defaults to: DATA_DIR="../data/editorImportedTasks" # the logout path as configured in the application config, defaults to: LOGOUT_PATH=login/logout/
Test Users
Test tasks are provided by each test independently, only the needed test users must exist in the Zf_users table of the translate5 instance to be tested. Import therefore the file "test-users.sql" available in the editorAPI directory.
Run Tests
To run the tests simply call:
./apitest.sh
The tests are based on PHPUnit, so output would be as expected from PHPUnit.
Create Tests
For creating tests see the already existing Tests "BasicSegmentEditingTest" and "SegmentWorkflowTest" in the directory "editorAPI":
editorAPI/ editorAPI/BasicSegmentEditingTest editorAPI/BasicSegmentEditingTest/testSegmentEditing-assert-seg7.json editorAPI/BasicSegmentEditingTest/testSegmentEditing-assert-seg3.json editorAPI/BasicSegmentEditingTest.php editorAPI/DummyTest.php editorAPI/MainTest editorAPI/MainTest/simple-en-de.zip editorAPI/MainTest/testfiles-relais-reference-terminology.zip editorAPI/SegmentWorkflowTest editorAPI/SegmentWorkflowTest/testWorkflowFinishAsLector-assert-equal.xliff editorAPI/SegmentWorkflowTest.php editorAPI/TaskEntityVersionTest.php editorAPI/test-users.sql
As convention all other files (source files, content files to be tested against, etc) are stored in directories with the same name as the test class (without .php).
One exception here, shared files are stored in MainTest.