This test suite contains unit tests and integration tests for the ReactPHP Unifi API Client.
- PHP 8.1 or higher
- Composer
- PHPUnit 10.5 or higher
- Mockery 1.6 or higher
- Xdebug (for code coverage reports)
composer installUnit tests can be run without a connection to a Unifi controller:
./vendor/bin/phpunit --testsuite UnitIntegration tests require a connection to a real Unifi controller. You need to set the following environment variables:
export UNIFI_HOST="https://unifi.example.com:8443"
export UNIFI_USERNAME="admin"
export UNIFI_PASSWORD="password"Then you can run the integration tests:
./vendor/bin/phpunit --testsuite IntegrationTo run all tests:
./vendor/bin/phpunitTo generate a code coverage report:
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverageThe report will be created in the coverage directory.
Unit/: Contains unit tests that mock external dependenciesServices/: Tests for individual service classesUnifiClientTest.php: Tests for the main client class
Integration/: Contains tests that interact with a real Unifi controllerServices/: Integration tests for service classesUnifiClientTest.php: Integration tests for the client
- Integration tests are skipped if the required environment variables are not set
- Tests use Mockery for mocking and PHPUnit for assertions
- The test suite is configured in the
phpunit.xmlfile in the project root