Skip to content

Package Verification

The test-isolated.sh script includes automatic package verification to ensure that only the correct framework packages are installed for each test variant.

Package verification prevents version conflicts and ensures test isolation by automatically checking that:

  1. Plain PHP - No framework packages are installed
  2. Laravel Tests - Only Laravel packages of the correct version
  3. Symfony Tests - Only Symfony packages of the correct version
  4. Doctrine Tests - Only Doctrine packages of the correct version

After installing dependencies, the script automatically verifies installed packages before running tests.

  1. Gets list of installed packages using composer show --format=json
  2. Checks for forbidden packages based on test type
  3. For framework tests, verifies that installed framework packages match the expected version
  4. Exits with error code 1 if any forbidden packages are found
  5. Prints detailed error messages showing which packages are problematic

Forbidden packages:

  • All illuminate/* packages
  • symfony/validator, symfony/http-kernel, symfony/http-foundation
  • doctrine/orm, doctrine/dbal

Example:

Terminal window
./scripts/test-isolated.sh --plain --php 8.4

Allowed packages:

  • illuminate/support, illuminate/validation, illuminate/database (matching version)
  • Other illuminate/* packages as dependencies (matching version)

Forbidden packages:

  • illuminate/* packages with wrong version
  • symfony/validator, symfony/http-kernel, symfony/http-foundation
  • doctrine/orm, doctrine/dbal

Note: Some Symfony components (like symfony/console, symfony/process) are allowed as they are dependencies of Laravel.

Examples:

Terminal window
./scripts/test-isolated.sh --laravel 10 --php 8.3
./scripts/test-isolated.sh --laravel 11 --php 8.4

Allowed packages:

  • symfony/validator, symfony/http-kernel, symfony/http-foundation (matching version)
  • Other symfony/* packages as dependencies (matching version)

Forbidden packages:

  • Symfony framework packages with wrong version
  • All illuminate/* packages
  • doctrine/orm, doctrine/dbal

Example:

Terminal window
./scripts/test-isolated.sh --symfony 7 --php 8.4

Allowed packages:

  • doctrine/orm, doctrine/dbal (matching version)
  • Other doctrine/* packages as dependencies (matching version)

Forbidden packages:

  • Doctrine packages with wrong version
  • All illuminate/* packages
  • symfony/validator, symfony/http-kernel, symfony/http-foundation

Note: Some Symfony components are allowed as they are dependencies of Doctrine.

Example:

Terminal window
./scripts/test-isolated.sh --doctrine 3 --php 8.4
Terminal window
Verifying installed packages...
Package verification passed
Terminal window
Verifying installed packages...
Found forbidden Laravel packages in Symfony setup:
illuminate/support
illuminate/validation
Package verification failed!

Package verification runs automatically during:

Terminal window
# Matrix tests
task test:matrix
# Individual framework tests
task test:laravel11
task test:symfony7
task test:doctrine3

To manually verify packages without running tests:

Terminal window
# Run with --no-tests to skip test execution
./scripts/test-isolated.sh --laravel 10 --php 8.2 --no-tests
# Check the output for "Package verification passed"
Terminal window
# Test all four variants (Plain PHP, Laravel, Symfony, Doctrine)
./scripts/test-package-verification.sh

Ensures only one framework version is installed at a time, preventing dependency conflicts.

Example:

Terminal window
# ❌ Without verification: Laravel 11 + Symfony 7 installed together
# ✅ With verification: Only Laravel 11 installed

Guarantees that tests run in the correct environment, mimicking real-world usage.

Example:

Terminal window
# ❌ Without verification: Tests might pass due to other frameworks
# ✅ With verification: Tests only pass if they work with the target framework

Catches dependency issues before running tests, saving time and providing clear feedback.

Example:

Terminal window
# ❌ Without verification: Tests fail with cryptic errors
# ✅ With verification: Clear error message about forbidden packages

Shows exactly which packages are problematic, making it easy to fix issues.

Example:

Terminal window
Found forbidden Laravel packages in Symfony setup:
illuminate/support v11.0.0
illuminate/validation v11.0.0

The verify_installed_packages function in scripts/test-isolated.sh:

Terminal window
verify_installed_packages() {
local test_type=$1
local version=$2
# Get installed packages
local packages=$(composer show --format=json)
# Check for forbidden packages
case $test_type in
plain)
check_no_frameworks
;;
laravel)
check_only_laravel "$version"
;;
symfony)
check_only_symfony "$version"
;;
doctrine)
check_only_doctrine "$version"
;;
esac
}
Terminal window
# Check if package is installed
if echo "$packages" | jq -e '.installed[] | select(.name == "illuminate/support")' > /dev/null; then
echo "✗ illuminate/support found"
exit 1
fi
# Check package version
local version=$(echo "$packages" | jq -r '.installed[] | select(.name == "illuminate/support") | .version')
if [[ ! "$version" =~ ^$expected_version ]]; then
echo "✗ Wrong version: $version (expected: $expected_version)"
exit 1
fi

If package verification fails:

  1. Check the error message - It shows which packages are problematic
  2. Clean composer cache:
    Terminal window
    task dev:clean
  3. Rebuild environment:
    Terminal window
    task dev:reset

If wrong packages are installed:

  1. Remove vendor and lock file:
    Terminal window
    rm -rf vendor composer.lock
  2. Reinstall dependencies:
    Terminal window
    task install

If verification is too strict for your use case:

  1. Check if the package is a dependency - Some Symfony components are allowed as Laravel dependencies
  2. Update verification rules - Edit scripts/test-isolated.sh if needed
  3. Report an issue - If you think the rules are incorrect

Package verification provides:

  • Prevents version conflicts - Only one framework at a time
  • Test isolation - Guarantees correct environment
  • Early detection - Catches issues before tests
  • Clear error messages - Shows exactly what’s wrong
  • Automatic - Runs during all matrix tests