#!/bin/bash

# Safe test runner that ensures testing database is used
echo "Setting up testing environment..."

# Set testing environment variables
export APP_ENV=testing
export DB_CONNECTION=testing
export DB_DATABASE=aipt_testing
export DB_HOST=127.0.0.1
export DB_PORT=3306
export DB_USERNAME=root
export DB_PASSWORD=""

echo "Environment variables set:"
echo "APP_ENV: $APP_ENV"
echo "DB_CONNECTION: $DB_CONNECTION"
echo "DB_DATABASE: $DB_DATABASE"

echo ""
echo "Running Patent module tests with safe database isolation..."
echo ""

# Run tests from project root with explicit configuration
cd ../../ && php vendor/bin/phpunit --configuration Modules/Patent/phpunit.xml Modules/Patent/Tests/

echo ""
echo "Tests completed!"
