Move test db connection to env#41
Open
fadrian06 wants to merge 9 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors MySQL tests to use environment-based DB connection settings (via .env.example.php with optional .env.php overrides) and removes a duplicated whereJson/JSON helper method block from src/Db.php.
Changes:
- Replace hardcoded MySQL connection literals in tests with values read from
$_ENV. - Add
.env.example.phpand ignore.env.phpto allow local test configuration without committing secrets. - Remove duplicated JSON-where methods in
src/Db.php.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mysql/leaf-builder.test.php | Switches to env-based DB connection, but currently lacks its own env/fixture setup. |
| tests/mysql/connect.test.php | Loads env config for tests and updates connection assertion to use connectSync. |
| src/Db.php | Removes duplicate JSON-where methods; remaining docblock needs correction. |
| .gitignore | Ignores .env.php to prevent committing local secrets. |
| .env.example.php | Introduces an env template for DB config (currently contains what appear to be real credentials). |
Comments suppressed due to low confidence (1)
src/Db.php:362
- The docblock on
whereJsonsays "Fetch current query with all related data", but the method actually adds a JSON where clause. This mismatch is confusing for IDEs and generated docs; update the summary to reflect the method’s behavior.
/**
* Fetch current query with all related data
*
* @param string $column The JSON column
* @param string $jsonKey The key within the JSON structure
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
Copilot stresses me out; I’m waiting for the opinion of real intelligence. P.S. The tests need a more thorough refactoring so that if they’re going to depend on order, it’s clearly defined. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (pls check at least one)
Description
This PR addresses an issue I ran into while running tests to continue contributing to the project, caused by hardcoded database connection literals in the tests. These literals are now refactored to pull from
.env.example.phpwith customization possible via.env.php. Before all tests could pass, I spotted a syntax problem in the Db class: the docblock for the firstwhereJsonmethod was missing the starting/, and that method along with its variants appeared twice. Removing the duplicates fixed the issue, and now all tests pass locally. I’m hoping this PR gets merged soon so I can keep contributing, particularly by helping resolve issues, enhancingsqlitesupport, and fixing problems when using the database without the Leaf core.Does this PR introduce a breaking change? (check one)