Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟡 Changes recommended
The WP_TEMP_DIR override test uses an already slash-terminated path on non-Windows systems, so it cannot detect whether that branch fails to add the required trailing slash.
1 open issue
What changed in this PR
Adds dedicated PHPUnit coverage for WordPress’s get_temp_dir() function, without changing production behavior.
Changes:
- Checks that the returned path has a trailing slash and identifies an existing, writable directory.
- Verifies that
WP_TEMP_DIRis respected, using a separate process to isolate the constant definition.
| File | Description |
|---|---|
tests/phpunit/tests/wp-includes/functions/GetTempDirTest.php |
Adds three tests covering temporary-directory behavior and the constant override. |
Review effort: Balanced
Remove trailing slashes from custom temp directory paths. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lancewillett
left a comment
There was a problem hiding this comment.
With WP_TEMP_DIR already set in the PHPUnit configuration, test_get_temp_dir_respects_constant() errors with “Constant WP_TEMP_DIR already defined” before it reaches its assertion. Running in a separate process still loads that configuration. Please define the custom path only when the constant is absent, then assert against trailingslashit( WP_TEMP_DIR ). I verified that version with and without a configured override. The override is a path supplied by the site, so its writability isn’t guaranteed by this function.
AI review · gpt-6

This PR adds dedicated unit tests for the get_temp_dir() function in wp-includes/functions.php.
The tests ensure that:
•The function returns a path with a trailing slash as expected by its consumers.
•The returned path is an existing, writable directory.
•The WP_TEMP_DIR constant is correctly respected when defined.
To accurately test the constant behaviour without affecting other tests or being affected by the function's internal static cache, @runInSeparateProcess is utilized for the constant-specific test case.
Trac ticket: https://core.trac.wordpress.org/ticket/65651
AI Disclosure:
•AI assistance: Yes
•Tool(s): Junie (JetBrains)
•Model(s): gemini-3-flash-preview
•Used for: Code analysis, test implementation, and workflow management.