Overview
Lionz IPTV Downloader uses Pest PHP for testing. Pest is a modern testing framework built on top of PHPUnit with an elegant, expressive syntax.Running Tests
All Tests
Specific Test Suites
The project has three test suites defined inphpunit.xml:
Specific Test Files
Filter by Test Name
With Coverage
Parallel Execution
Test Structure
Directory Organization
Test Configuration
Pest is configured intests/Pest.php:
- Extends Laravel’s
TestCasefor all test directories - Configures browser tests to use Chrome in light mode
PHPUnit Configuration
Thephpunit.xml file defines:
Test Environment:
- In-memory SQLite database
- Array cache driver
- Synchronous queue
- Disabled monitoring tools
Writing Tests
Basic Pest Syntax
Pest uses a functional, expressive syntax:Feature Test Example
Fromtests/Feature/Downloads/DownloadRetryPolicyTest.php:42-94:
uses(RefreshDatabase::class)for database isolationafterEach()for cleanup- Helper functions for test setup
- Saloon
MockClientfor API mocking Queue::fake()andQueue::assertPushed()for queue testing
Architecture Tests
Fromtests/Architecture/GeneralTest.php:
- PHP best practices (no
eval,die, etc.) - Security rules (no debug functions in production)
- Laravel conventions (controllers don’t use models directly, etc.)
- With exceptions for API integration classes
Browser Tests
The project uses Pest Browser (Playwright) for E2E tests:- Sets up Playwright Chromium executable
- Runs tests in
tests/Browser/
Testing Best Practices
1. Database Testing
Always useRefreshDatabase trait:
2. Mocking External Services
Saloon HTTP Mocking:3. Time Testing
4. Helper Functions
Create test helper functions at the bottom of test files:5. Test Isolation
Each test should be independent:6. Expectations
Pest provides expressive expectations:7. HTTP Testing
Continuous Integration
GitHub Actions runs tests automatically on push/PR. From.github/workflows/tests.yml:47-48:
- Checks out code
- Sets up PHP 8.4 with Xdebug
- Sets up Bun
- Installs frontend dependencies
- Builds assets
- Installs Composer dependencies
- Configures Laravel
- Runs Pest tests
Test Coverage
Generate coverage report:coverage/index.html in a browser.
Common Test Patterns
Testing Actions
Testing Jobs
Testing Controllers
Tips
- Run tests frequently during development
- Write tests before fixing bugs (TDD)
- Keep tests fast by mocking external services
- Use descriptive test names that explain intent
- Group related assertions in a single test
- Use
dd()ordump()for debugging tests - Check test output for helpful error messages