#!/bin/bash

# Configure PHPUnit in staging environment
echo "Configuring PHPUnit for staging environment..."

# 1. Verify PHPUnit installation
if command -v phpunit &> /dev/null; then
    PHPUNIT_CMD="phpunit"
    echo "Using system PHPUnit installation"
else
    PHPUNIT_CMD="./vendor/bin/phpunit"
    echo "Using vendor PHPUnit installation"
fi

# 2. Update test scripts with the PHPUnit command
sed -i '' "s|phpunit|${PHPUNIT_CMD}|g" run-simplified-tests.sh
sed -i '' "s|phpunit|${PHPUNIT_CMD}|g" run-basic-tests.sh
sed -i '' "s|phpunit|${PHPUNIT_CMD}|g" run-staging-tests.sh

# 3. Make scripts executable
chmod +x run-simplified-tests.sh
chmod +x run-basic-tests.sh
chmod +x run-staging-tests.sh

echo "PHPUnit configuration complete"
echo "Test scripts updated to use: ${PHPUNIT_CMD}"