Skip to content

Commit 37556d8

Browse files
committed
fix: update test-examples.sh to check MSSQL via environment variables
- Check DB_USER and DB_PASS environment variables first (for CI) - Fallback to config.mssql.php file if environment variables not set - Add TrustServerCertificate=yes to DSN when using environment variables
1 parent fd3c54c commit 37556d8

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

scripts/test-examples.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,29 @@ else
9292
fi
9393

9494
# Check MSSQL
95-
if [ -f "examples/config.mssql.php" ]; then
95+
# First check if environment variables are set (CI), then fallback to config file
96+
if [ -n "$DB_USER" ] && [ -n "$DB_PASS" ]; then
97+
# Use environment variables (CI)
98+
if php -r "
99+
\$host = getenv('DB_HOST') ?: 'localhost';
100+
\$port = getenv('DB_PORT') ?: '1433';
101+
\$dbname = getenv('DB_NAME') ?: 'testdb';
102+
\$username = getenv('DB_USER');
103+
\$password = getenv('DB_PASS');
104+
try {
105+
\$dsn = 'sqlsrv:Server=' . \$host . ',' . \$port . ';Database=' . \$dbname . ';TrustServerCertificate=yes';
106+
new PDO(\$dsn, \$username, \$password);
107+
exit(0);
108+
} catch (Exception \$e) {
109+
exit(1);
110+
}
111+
" 2>/dev/null; then
112+
MSSQL_AVAILABLE=1
113+
echo -e "${GREEN}✓ MSSQL available (via environment variables)${NC}"
114+
else
115+
echo -e "${YELLOW}⊘ MSSQL not available (environment variables set but connection failed)${NC}"
116+
fi
117+
elif [ -f "examples/config.mssql.php" ]; then
96118
if php -r "
97119
\$config = require 'examples/config.mssql.php';
98120
try {

0 commit comments

Comments
 (0)