Files
crewsportswear/test-upgrade.sh
2026-01-07 02:03:27 +08:00

100 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Quick functionality test script for Laravel upgrade
# Run this after each upgrade step to verify core features
set -e
CONTAINER_NAME="crewsportswear_app_local"
BASE_URL="http://localhost:8082"
echo "=========================================="
echo "Laravel Upgrade - Functionality Tests"
echo "=========================================="
echo ""
# Check if container is running
if ! docker ps | grep -q "$CONTAINER_NAME"; then
echo "❌ Container $CONTAINER_NAME is not running"
echo " Start it with: docker compose -f docker-compose.local.yml up -d"
exit 1
fi
echo "✓ Container is running"
echo ""
# Test 1: Artisan commands
echo "Test 1: Artisan Commands"
echo "------------------------"
docker exec $CONTAINER_NAME php artisan --version || { echo "❌ Artisan failed"; exit 1; }
echo "✓ Artisan working"
echo ""
# Test 2: Route list
echo "Test 2: Route Discovery"
echo "------------------------"
docker exec $CONTAINER_NAME php artisan route:list | head -5 || echo "⚠️ Route list not available (normal for Laravel 5.0-5.2)"
echo "✓ Route system loaded"
echo ""
# Test 3: Database connection
echo "Test 3: Database Connection"
echo "----------------------------"
docker exec $CONTAINER_NAME php artisan tinker --execute="DB::connection()->getPdo(); echo 'DB Connected';" || { echo "❌ Database connection failed"; exit 1; }
echo "✓ Database connected"
echo ""
# Test 4: HTTP Response (if app is running)
echo "Test 4: HTTP Response"
echo "----------------------"
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" $BASE_URL 2>/dev/null || echo "000")
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "✓ HTTP server responding (Status: $HTTP_CODE)"
elif [ "$HTTP_CODE" = "500" ]; then
echo "⚠️ Server error (500) - Check logs"
else
echo "⚠️ Unexpected response: $HTTP_CODE"
fi
echo ""
# Test 5: View compilation
echo "Test 5: View Compilation"
echo "-------------------------"
docker exec $CONTAINER_NAME php artisan view:clear || echo "⚠️ View clear unavailable"
echo "✓ Views can be cleared"
echo ""
# Test 6: Cache operations
echo "Test 6: Cache System"
echo "---------------------"
docker exec $CONTAINER_NAME php artisan cache:clear || { echo "❌ Cache clear failed"; exit 1; }
echo "✓ Cache system working"
echo ""
# Test 7: Config cache (optional)
echo "Test 7: Config System"
echo "----------------------"
docker exec $CONTAINER_NAME php artisan config:clear || echo "⚠️ Config clear unavailable"
echo "✓ Config system accessible"
echo ""
# Show recent logs
echo "Test 8: Error Logs"
echo "-------------------"
docker exec $CONTAINER_NAME sh -c "tail -20 /var/www/html/storage/logs/laravel.log 2>/dev/null || echo 'No log file yet (expected on fresh install)'"
echo ""
echo "=========================================="
echo "✓ Basic functionality tests passed!"
echo "=========================================="
echo ""
echo "Manual tests needed:"
echo " 1. Visit $BASE_URL in browser"
echo " 2. Test user registration/login"
echo " 3. Test sports category pages"
echo " 4. Test designer tool"
echo " 5. Test cart functionality"
echo ""
echo "View logs: docker logs $CONTAINER_NAME"
echo "Access shell: docker exec -it $CONTAINER_NAME bash"
echo ""