Make WordPress Core

Opened 7 weeks ago

Last modified 5 weeks ago

#65136 new enhancement

Unit Tests: Add tests for extract_from_markers() and stop empty values being returned

Reported by: pbearne's profile pbearne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: tests Cc:

Description

The function extract_from_markers() in src/wp-admin/includes/misc.php lacks unit tests. This PR adds tests to ensure it correctly extracts content between markers in a file, handling missing files, different markers, and comments.

Change History (4)

This ticket was mentioned in PR #11658 on WordPress/wordpress-develop by @pbearne.


7 weeks ago
#1

  • Keywords has-patch has-unit-tests added

…sc.php

Reference: https://core.trac.wordpress.org/ticket/65136

This PR adds unit tests for the extract_from_markers() function in src/wp-admin/includes/misc.php.
The tests cover:

  • Extraction from a standard WordPress .htaccess block.
  • Handling of comments within markers.
  • Multiple marker blocks.
  • Non-existent files and missing markers.

Trac ticket: https://core.trac.wordpress.org/ticket/65136

## Use of AI Tools
AI assistance: Yes
Tool(s): Junie (JetBrains)
Model(s): gemini-3-flash-preview
Used for: Generating test cases, implementing set_up/tear_down for temporary file management, and validating extraction logic.

#2 @pbearne
7 weeks ago

  • Keywords has-patch has-unit-tests removed
  • Summary changed from Unit Tests: Add tests for extract_from_markers() to Unit Tests: Add tests for extract_from_markers() and stop empty values being returned

In testing, I found that empty lines where beeing return in the array of values

Add code to stop this

#3 @pbearne
7 weeks ago

  • Keywords has-patch has-unit-tests added

#4 @desrosj
5 weeks ago

  • Focuses tests added

Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.

Note: See TracTickets for help on using tickets.