Skip to content

Commit 9778088

Browse files
committed
fix: preserve PDODB_USERNAME and PDODB_PASSWORD in OptimizeCommandCliTests tearDown
Fixed issue where OptimizeCommandCliTests::tearDown() was clearing PDODB_USERNAME and PDODB_PASSWORD environment variables, causing subsequent tests to fail with 'Login failed for user testuser' error. The problem occurred because: 1. OptimizeCommandCliTests runs and sets environment variables in setUp() 2. tearDown() clears all environment variables including PDODB_USERNAME/PASSWORD 3. Subsequent tests that create new connections cannot read credentials 4. They fall back to default testuser/testpass which don't exist in CI Solution: - Keep PDODB_USERNAME and PDODB_PASSWORD in tearDown() as they are needed by other tests that may create new PdoDb instances - Only clear test-specific variables (DRIVER, HOST, PORT, DATABASE) This ensures that environment variables from GitHub Actions (sa/Test123!@#) remain available for all tests throughout the test suite execution.
1 parent 0b2f0af commit 9778088

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/mssql/OptimizeCommandCliTests.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ public function setUp(): void
3838
public function tearDown(): void
3939
{
4040
// Clean up environment variables to avoid affecting other tests
41+
// Note: Do not clear PDODB_USERNAME and PDODB_PASSWORD as they are needed
42+
// by other tests that may create new connections
4143
putenv('PDODB_DRIVER');
4244
putenv('PDODB_HOST');
4345
putenv('PDODB_PORT');
4446
putenv('PDODB_DATABASE');
45-
putenv('PDODB_USERNAME');
46-
putenv('PDODB_PASSWORD');
47+
// Keep PDODB_USERNAME and PDODB_PASSWORD for other tests
48+
// putenv('PDODB_USERNAME');
49+
// putenv('PDODB_PASSWORD');
4750
putenv('PDODB_NON_INTERACTIVE');
4851
parent::tearDown();
4952
}

0 commit comments

Comments
 (0)