This guide is for contributors and developers working on the php-discogs-api library itself.
# Unit tests (fast, CI-compatible, no external dependencies)
composer test
# Integration tests (requires Discogs API credentials)
composer test-integration
# All tests together (unit + integration)
composer test-all
# Code coverage (HTML + XML reports)
composer test-coverage# Static analysis (PHPStan Level 8)
composer analyse
# Code style check (PSR-12)
composer cs
# Auto-fix code style
composer cs-fixIntegration tests are separated from the CI pipeline to prevent:
- 🚫 Rate limiting (429 Too Many Requests)
- 🚫 Flaky builds due to network issues
- 🚫 Dependency on external API availability
- 🚫 Slow build times (2+ minutes vs. 0.4 seconds)
- Unit Tests: Fast, reliable, no external dependencies → CI default
- Integration Tests: Real API calls, rate-limited → Manual execution
- Total Coverage: 100% lines, methods, and classes covered
To enable authenticated integration tests in CI/CD, add these secrets to your GitHub repository:
| Secret Name | Description | Where to get it |
|---|---|---|
DISCOGS_CONSUMER_KEY |
Your Discogs app consumer key | Discogs Developer Settings |
DISCOGS_CONSUMER_SECRET |
Your Discogs app consumer secret | Discogs Developer Settings |
DISCOGS_PERSONAL_ACCESS_TOKEN |
Your personal access token | Discogs Developer Settings |
DISCOGS_OAUTH_TOKEN |
OAuth access token (optional) | OAuth flow result |
DISCOGS_OAUTH_TOKEN_SECRET |
OAuth token secret (optional) | OAuth flow result |
- File:
tests/Integration/PublicApiIntegrationTest.php - No credentials required
- Tests public endpoints: artists, releases, labels, masters
- Safe for forks and pull requests
- File:
tests/Integration/AuthenticationLevelsTest.php - Requires all three secrets above
- Tests all four authentication levels:
- Level 1: No auth (public data)
- Level 2: Consumer credentials (search)
- Level 3: Personal token (user data)
- Level 4: OAuth (interactive flow, tested when tokens are available)
# Set environment variables
export DISCOGS_CONSUMER_KEY="your-consumer-key"
export DISCOGS_CONSUMER_SECRET="your-consumer-secret"
export DISCOGS_PERSONAL_ACCESS_TOKEN="your-personal-access-token"
# Run integration tests (public tests run without credentials, auth tests skip if no credentials)
composer test-integration
# Run all tests (unit + integration) with detailed output
composer test-all -- --testdox- Public tests are safe for any environment
- Authentication tests will be skipped if secrets are missing
- No credentials are logged or exposed in the test output
- Tests use read-only operations only (no data modification)
- Fork the repository
- Create feature branch (
git checkout -b feature/name) - Make changes with tests
- Run test suite (
composer test-all) - Check code quality (
composer analyse && composer cs) - Commit changes (
git commit -m 'Add feature') - Push to branch (
git push origin feature/name) - Open Pull Request
- PHP Version: ^8.1
- Code Style: PSR-12 (enforced by PHP-CS-Fixer)
- Static Analysis: PHPStan Level 8
- Test Coverage: 100% lines, methods, and classes
- Dependencies: Minimal (only Guzzle required)
The library consists of only four main classes:
DiscogsClient- Main API client with magic method callsDiscogsClientFactory- Factory for creating authenticated clientsOAuthHelper- OAuth 1.0a flow helperConfigCache- Service configuration cache
Simple, focused architecture with minimal dependencies.