-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
Run the full test suite from the repository root:
# All tests
composer test
# Unit tests only
composer test:unit
# Cross-SDK parity tests
composer test:cross-sdk
# Integration tests
composer test:integration
# Coverage report (requires PCOV)
composer test:coverage# PHPStan (level 6)
composer analyze
# PHP-CS-Fixer (PSR-12)
composer cs-check
# Fix code style
composer cs-fixThe integration test suite supports three auth modes, each running the full test suite:
- static — uses a bundled JSON config file (no network calls)
-
live — fetches config from the staging CDN using
sdkKeyonly (requiresCONVERT_STAGING_SDK_KEY) -
live-secret — fetches config using
sdkKey+sdkKeySecretBearer auth (requiresCONVERT_STAGING_SDK_KEY2andCONVERT_STAGING_SDK_KEY2_SECRET)
When the required env vars for a live mode are absent, those tests are skipped automatically — unit and static-mode tests still run normally.
PHP's getenv() reads OS-level environment variables only (not .env files). You must export the variables in your shell before running the tests:
export CONVERT_STAGING_SDK_KEY=xxx CONVERT_STAGING_SDK_KEY2=yyy CONVERT_STAGING_SDK_KEY2_SECRET=zzz && composer test:integrationOr set and run in one line without persisting:
CONVERT_STAGING_SDK_KEY=xxx CONVERT_STAGING_SDK_KEY2=yyy CONVERT_STAGING_SDK_KEY2_SECRET=zzz composer test:integrationNote: Because
getenv()only reads OS-level environment variables, libraries likevlucas/phpdotenvthat populate$_ENVor$_SERVERwill not make these values visible to the SDK. Always useexportor inline assignment as shown above.
| Variable | Used By | Default | Description |
|---|---|---|---|
CONVERT_STAGING_SDK_KEY |
Integration tests | (none — live tests skipped when absent) | SDK key for the Convert staging project. Enables live mode integration tests that fetch real config and post real tracking events. |
CONVERT_STAGING_SDK_KEY2 |
Integration tests | (none — live-secret tests skipped when absent) | SDK key for the live-secret auth mode. Used with sdkKeySecret to test Bearer-authenticated config fetching. |
CONVERT_STAGING_SDK_KEY2_SECRET |
Integration tests | (none — live-secret tests skipped when absent) | SDK key secret for the live-secret auth mode. Sent as a Bearer token in the Authorization header. |
CONFIG_ENDPOINT |
SDK runtime | https://cdn-4.convertexperiments.com/api/v1 |
Override the CDN endpoint used to fetch project configuration. Useful for pointing at a staging or local server. |
TRACK_ENDPOINT |
SDK runtime | https://[project_id].metrics.convertexperiments.com/v1 |
Override the Tracking API endpoint used to post events. [project_id] is replaced at runtime with the actual project ID. |
VERSION |
SDK runtime | php-sdk |
Override the source identifier sent with tracking requests (the network.source field). |
Copyrights © 2026 All Rights Reserved by Convert Insights, Inc.
Getting Started
PHP SDK
- Quickstart
- Installation
- Initialization
- Configuration
- Return Types & DTOs
- Code Examples
- Segments Manager
Core Concepts
- Experiences & Variations
- Feature Flags
- Bucketing Algorithm
- Rule Evaluation
- Segments
- Data Management
- Event System
- API Communication
How-To Guides
- Running Experiences
- Running Features
- Tracking Conversions
- Visitor Context
- Persistent DataStore
- Troubleshooting
Contributing