summaryrefslogtreecommitdiffhomepage
path: root/vhosts/t/phpcon-kagawa-2025/tests/test_404.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vhosts/t/phpcon-kagawa-2025/tests/test_404.sh')
-rwxr-xr-xvhosts/t/phpcon-kagawa-2025/tests/test_404.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/vhosts/t/phpcon-kagawa-2025/tests/test_404.sh b/vhosts/t/phpcon-kagawa-2025/tests/test_404.sh
new file mode 100755
index 0000000..509dfdb
--- /dev/null
+++ b/vhosts/t/phpcon-kagawa-2025/tests/test_404.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Test for 404 Not Found response
+
+BASE_URL="${BASE_URL:-http://127.0.0.1:8080}"
+PASSED=0
+FAILED=0
+
+echo "Testing 404 Not Found"
+echo "====================="
+
+# Test 1: GET / returns 404
+echo -n "Test 1: GET / returns 404... "
+response=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/")
+if [ "$response" = "404" ]; then
+ echo "PASSED"
+ ((PASSED++))
+else
+ echo "FAILED (got $response)"
+ ((FAILED++))
+fi
+
+# Test 2: GET /nonexistent returns 404
+echo -n "Test 2: GET /nonexistent returns 404... "
+response=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/nonexistent")
+if [ "$response" = "404" ]; then
+ echo "PASSED"
+ ((PASSED++))
+else
+ echo "FAILED (got $response)"
+ ((FAILED++))
+fi
+
+# Test 3: GET /foo/bar returns 404
+echo -n "Test 3: GET /foo/bar returns 404... "
+response=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/foo/bar")
+if [ "$response" = "404" ]; then
+ echo "PASSED"
+ ((PASSED++))
+else
+ echo "FAILED (got $response)"
+ ((FAILED++))
+fi
+
+# Test 4: 404 response body contains "404 Not Found"
+echo -n "Test 4: 404 response body contains '404 Not Found'... "
+content=$(curl -s "$BASE_URL/nonexistent")
+if [ "$content" = "404 Not Found" ]; then
+ echo "PASSED"
+ ((PASSED++))
+else
+ echo "FAILED (got '$content')"
+ ((FAILED++))
+fi
+
+echo ""
+echo "Results: $PASSED passed, $FAILED failed"
+
+if [ $FAILED -gt 0 ]; then
+ exit 1
+fi
+exit 0