Testing
This guide explains how to test the Laravel USSD package.
Running Tests
Run All Tests
composer test
# or
vendor/bin/phpunit
Run Specific Test Suites
# Run only unit tests
vendor/bin/phpunit tests/Unit
# Run only feature tests
vendor/bin/phpunit tests/Feature
# Run a specific test file
vendor/bin/phpunit tests/Feature/UssdFlowTest.php
Test Structure
Unit Tests
Test individual components in isolation:
-
MenuTest.php- Menu builder functionality -
UssdResponseTest.php- Response formatting
Feature Tests
Test complete flows and integrations:
-
UssdFlowTest.php- Basic USSD flow testing -
SessionContinuityTest.php- Session resume functionality
Testing in a Real Laravel Application
To test the package in a real Laravel application, you can add it as a local path repository in your test app's composer.json:
{
"repositories": [
{
"type": "path",
"url": "../laravel-ussd"
}
],
"require": {
"catalysteria/laravel-ussd": "@dev"
}
}
Then install and test:
composer update catalysteria/laravel-ussd
php artisan vendor:publish --provider="Vendor\\LaravelUssd\\Providers\\LaravelUssdServiceProvider"
php artisan ussd:state WelcomeState