Skip to content

Commit 2df0b39

Browse files
authored
Merge branch 'trunk' into add/execute-actions
2 parents 9841dd9 + 94d950a commit 2df0b39

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Join the `#core-ai` channel [on WordPress Slack](http://wordpress.slack.com) ([s
1313
In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Abilities API plugin must follow these requirements:
1414

1515
- **WordPress**: The plugin's minimum WordPress version requirement is 6.8.
16-
- **PHP**: The minimum required version of the code slated for WordPress Core includes is PHP7.2, but the tooling and development environment requires PHP 7.4 or higher.
16+
- **PHP**: The minimum required version of the code slated for WordPress Core includes PHP 7.2, but the tooling and development environment requires PHP 7.4 or higher.
1717

18-
We include [several tools](#useful-commands) to help ensure your code meets contribution
18+
We include [several tools](#useful-commands) to help ensure your code meets contribution requirements.
1919

2020
## Guidelines
2121

includes/rest-api/endpoints/class-wp-rest-abilities-list-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ public function get_items( $request ) {
128128
if ( $page > 1 ) {
129129
$prev_page = $page - 1;
130130
$prev_link = add_query_arg( 'page', $prev_page, $base );
131-
$response->add_link( 'prev', $prev_link );
131+
$response->link_header( 'prev', $prev_link );
132132
}
133133

134134
if ( $page < $max_pages ) {
135135
$next_page = $page + 1;
136136
$next_link = add_query_arg( 'page', $next_page, $base );
137-
$response->add_link( 'next', $next_link );
137+
$response->link_header( 'next', $next_link );
138138
}
139139

140140
return $response;

tests/unit/rest-api/wpRestAbilitiesListController.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,33 +294,40 @@ public function test_head_request(): void {
294294
* Test pagination links.
295295
*/
296296
public function test_pagination_links(): void {
297-
// Test first page (should have 'next' link but no 'prev')
297+
// Test first page (should have 'next' link header but no 'prev')
298298
$request = new WP_REST_Request( 'GET', '/wp/v2/abilities' );
299299
$request->set_param( 'per_page', 10 );
300300
$request->set_param( 'page', 1 );
301301
$response = $this->server->dispatch( $request );
302302

303-
$links = $response->get_links();
304-
$this->assertArrayHasKey( 'next', $links );
305-
$this->assertArrayNotHasKey( 'prev', $links );
303+
$headers = $response->get_headers();
304+
$link_header = $headers['Link'] ?? '';
305+
306+
// Parse Link header for rel="next" and rel="prev"
307+
$this->assertStringContainsString( 'rel="next"', $link_header );
308+
$this->assertStringNotContainsString( 'rel="prev"', $link_header );
306309

307-
// Test middle page (should have both 'next' and 'prev' links)
310+
// Test middle page (should have both 'next' and 'prev' link headers)
308311
$request->set_param( 'page', 3 );
309312
$response = $this->server->dispatch( $request );
310313

311-
$links = $response->get_links();
312-
$this->assertArrayHasKey( 'next', $links );
313-
$this->assertArrayHasKey( 'prev', $links );
314+
$headers = $response->get_headers();
315+
$link_header = $headers['Link'] ?? '';
314316

315-
// Test last page (should have 'prev' link but no 'next')
317+
$this->assertStringContainsString( 'rel="next"', $link_header );
318+
$this->assertStringContainsString( 'rel="prev"', $link_header );
319+
320+
// Test last page (should have 'prev' link header but no 'next')
316321
$total_abilities = count( wp_get_abilities() );
317322
$last_page = ceil( $total_abilities / 10 );
318323
$request->set_param( 'page', $last_page );
319324
$response = $this->server->dispatch( $request );
320325

321-
$links = $response->get_links();
322-
$this->assertArrayNotHasKey( 'next', $links );
323-
$this->assertArrayHasKey( 'prev', $links );
326+
$headers = $response->get_headers();
327+
$link_header = $headers['Link'] ?? '';
328+
329+
$this->assertStringNotContainsString( 'rel="next"', $link_header );
330+
$this->assertStringContainsString( 'rel="prev"', $link_header );
324331
}
325332

326333
/**

0 commit comments

Comments
 (0)