Commit bffde3b1429 for woocommerce
commit bffde3b1429dbf7e47a86c9da4f6ac1fad7e6cdf
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date: Wed Jul 29 19:43:45 2026 +0300
[dev] Fix reviews row test for the WP 7.1 check-column markup (#67122)
* test: Accept the WP 7.1 check-column markup in the reviews row test
ReviewsListTableTest::test_single_row asserted the literal
<th scope="row" class="check-column"></th> in the rendered review row.
WordPress 7.1-beta4 changed WP_List_Table's check column cell from <th>
to <td>, so the WP pre-release CI job now fails while WooCommerce still
supports older WordPress versions that render the <th> markup.
Assert the empty check-column cell through a regular expression that
accepts either tag, using a backreference so mismatched opening and
closing tags still fail.
* test: Use a named backreference in the check-column assertion
The check-column regex used a positional \1 backreference, which turns
brittle if another capture group is ever added, and the repository's
regex guidelines call for named groups. Capture the cell tag as a named
group and reference it with \k<cell_tag>; behavior is unchanged.
diff --git a/plugins/woocommerce/changelog/fix-reviews-list-table-check-column-test b/plugins/woocommerce/changelog/fix-reviews-list-table-check-column-test
new file mode 100644
index 00000000000..6e15965c6ca
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-reviews-list-table-check-column-test
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Accept the WordPress 7.1 list table check-column markup in the reviews list table row test.
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsListTableTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsListTableTest.php
index d8ad004c9d3..06880fee523 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsListTableTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsListTableTest.php
@@ -74,7 +74,14 @@ class ReviewsListTableTest extends WC_Unit_Test_Case {
if ( 'cb' !== $column_id ) {
$this->assertStringContainsString( 'data-colname="' . $column_name . '"', $row_output );
} else {
- $this->assertStringContainsString( '<th scope="row" class="check-column"></th>', $row_output );
+ // WordPress 7.1 changed the list table check column cell from <th> to <td>.
+ // Accept either element; the backreference requires the closing tag to
+ // match the captured opening tag.
+ $this->assertMatchesRegularExpression(
+ '~<(?<cell_tag>th|td)[^>]*\bclass="check-column"></\k<cell_tag>>~',
+ $row_output,
+ 'The row should contain an empty check-column cell.'
+ );
}
}