Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
58
app/RSpade/tests/basic/02_database_connection/README.md
Executable file
58
app/RSpade/tests/basic/02_database_connection/README.md
Executable file
@@ -0,0 +1,58 @@
|
||||
# Database Connection Test
|
||||
|
||||
Tests basic database CRUD operations using the test database.
|
||||
|
||||
## What it verifies
|
||||
|
||||
- Database insert operations work
|
||||
- Database query operations work
|
||||
- Database update operations work
|
||||
- Database delete operations work
|
||||
- Data retrieval returns correct values
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- `rspade_test` database exists
|
||||
- `rspade` user has access to `rspade_test`
|
||||
- Test environment helpers functional
|
||||
|
||||
## How to run
|
||||
|
||||
```bash
|
||||
./run_test.sh # Full test with database reset
|
||||
./run_test.sh --skip-reset # Skip database reset (faster)
|
||||
```
|
||||
|
||||
## What happens
|
||||
|
||||
1. Creates temporary table
|
||||
2. Inserts test data
|
||||
3. Verifies data was inserted
|
||||
4. Queries specific data
|
||||
5. Updates data
|
||||
6. Verifies update worked
|
||||
7. Deletes data
|
||||
8. Verifies deletion worked
|
||||
9. Cleans up (temporary table auto-removed)
|
||||
|
||||
## Expected output
|
||||
|
||||
```
|
||||
[SETUP] Preparing database connection test...
|
||||
[SETUP] Resetting test database...
|
||||
[DB RESET] Dropping rspade_test database...
|
||||
[DB RESET] Creating rspade_test database...
|
||||
[DB RESET] Running migrations...
|
||||
[DB RESET] Database reset complete
|
||||
[TEST ENV] Entering test mode...
|
||||
[TEST ENV] Test mode active (using rspade_test database)
|
||||
[TEST] Testing database connection and operations...
|
||||
[TEST] ✓ Insert operations work
|
||||
[TEST] ✓ Query operations work
|
||||
[TEST] ✓ Data retrieval works
|
||||
[TEST] ✓ Update operations work
|
||||
[TEST] ✓ Delete operations work
|
||||
PASS: Database Connection
|
||||
[TEST ENV] Exiting test mode...
|
||||
[TEST ENV] Test mode exited (restored original database)
|
||||
```
|
||||
85
app/RSpade/tests/basic/02_database_connection/run_test.sh
Executable file
85
app/RSpade/tests/basic/02_database_connection/run_test.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
TEST_NAME="Database Connection"
|
||||
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Source test environment helpers
|
||||
source "$TEST_DIR/../../_lib/test_env.sh"
|
||||
|
||||
# Parse arguments
|
||||
SKIP_RESET=false
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--skip-reset)
|
||||
SKIP_RESET=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Ensure test mode exits on script exit (success or failure)
|
||||
trap test_trap_exit EXIT
|
||||
|
||||
# SETUP
|
||||
echo "[SETUP] Preparing database connection test..." >&2
|
||||
|
||||
# Enter test mode (switches Laravel to rspade_test database and loads test config)
|
||||
test_mode_enter
|
||||
|
||||
# Reset database to known state (unless called as sub-test)
|
||||
if [ "$SKIP_RESET" = false ]; then
|
||||
"$TEST_DIR/../../_lib/db_reset.sh"
|
||||
fi
|
||||
|
||||
# TEST LOGIC
|
||||
echo "[TEST] Testing database connection and operations..." >&2
|
||||
|
||||
# Test 1: Can we insert data?
|
||||
test_db_query "CREATE TABLE IF NOT EXISTS rspade_test_temp_users (id INT, name VARCHAR(255))"
|
||||
test_db_query "TRUNCATE TABLE rspade_test_temp_users"
|
||||
test_db_query "INSERT INTO rspade_test_temp_users (id, name) VALUES (1, 'Alice'), (2, 'Bob')"
|
||||
echo "[TEST] ✓ Insert operations work" >&2
|
||||
|
||||
# Test 2: Can we query data?
|
||||
count=$(test_db_count rspade_test_temp_users)
|
||||
if [ "$count" -ne 2 ]; then
|
||||
echo "FAIL: $TEST_NAME - Expected 2 rows, found $count"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST] ✓ Query operations work" >&2
|
||||
|
||||
# Test 3: Can we retrieve specific data?
|
||||
name=$(test_db_query "SELECT name FROM rspade_test_temp_users WHERE id=1")
|
||||
if [ "$name" != "Alice" ]; then
|
||||
echo "FAIL: $TEST_NAME - Expected 'Alice', got '$name'"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST] ✓ Data retrieval works" >&2
|
||||
|
||||
# Test 4: Can we update data?
|
||||
test_db_query "UPDATE rspade_test_temp_users SET name='Charlie' WHERE id=1"
|
||||
updated_name=$(test_db_query "SELECT name FROM rspade_test_temp_users WHERE id=1")
|
||||
if [ "$updated_name" != "Charlie" ]; then
|
||||
echo "FAIL: $TEST_NAME - Expected 'Charlie', got '$updated_name'"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST] ✓ Update operations work" >&2
|
||||
|
||||
# Test 5: Can we delete data?
|
||||
test_db_query "DELETE FROM rspade_test_temp_users WHERE id=2"
|
||||
remaining=$(test_db_count rspade_test_temp_users)
|
||||
if [ "$remaining" -ne 1 ]; then
|
||||
echo "FAIL: $TEST_NAME - Expected 1 row after delete, found $remaining"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST] ✓ Delete operations work" >&2
|
||||
|
||||
# Cleanup
|
||||
test_db_query "DROP TABLE IF EXISTS rspade_test_temp_users"
|
||||
|
||||
# All tests passed
|
||||
echo "PASS: $TEST_NAME"
|
||||
exit 0
|
||||
|
||||
# TEARDOWN happens automatically via trap
|
||||
Reference in New Issue
Block a user