-
-
Notifications
You must be signed in to change notification settings - Fork 28
How to test your extension with phpunit and TravisCI
-
Go to Travis Accounts, Sync the list of repositories, Enable your extensions repository
-
Copy the following files to your extension:
travis/prepare-phpbb.sh .travis.yml phpunit.xml.dist
NOTE: You need to set the executable permission for
travis/prepare-phpbb.sh
. To do so, you can run the following command:git update-index --chmod=+x travis/prepare-phpbb.sh
-
Edit
.travis.yml
find:
- EXTNAME="acme/demo" # CHANGE name of the extension HERE
replace with:
- EXTNAME="yourvendor/yourextension"
Example:
- EXTNAME="nickvergessen/newspage"
-
If you want to run EPV on your extension as well, you need to include EPV as development dependency in composer.json
"require-dev": { "phpbb/epv": "dev-master" }, ``` After that run composer.phar update to create the composer.lock file needed for travis. 4. Finished! Now write your tests.
* See [tests/controller/main_test.php](https://github.com/nickvergessen/phpbb-ext-acme-demo/blob/master/tests/controller/main_test.php) for a simple plain php test.
* See [tests/dbal/simple_test.php](https://github.com/nickvergessen/phpbb-ext-acme-demo/blob/master/tests/dbal/simple_test.php) for a simple test that requires the database.
* See [tests/functional/demo_test.php](https://github.com/nickvergessen/phpbb-ext-acme-demo/blob/master/tests/functional/demo_test.php) for a simple test that visits a webpage with a faked browser.
(Note: these tests are not run on php 5.3.3 on travis, as travis does not allow setting up a webserver for 5.3.3)
Testing your code will help you to avoid making the same mistakes over and over again.
To run the tests locally, you need to install phpBB from its Git repository. Afterwards run the following command from the phpBB Git repository's root:
Windows:
phpBB\vendor\bin\phpunit.bat -c phpBB\ext\acme\demo\phpunit.xml.dist
others:
phpBB/vendor/bin/phpunit -c phpBB/ext/acme/demo/phpunit.xml.dist