Skip to content

Commit 8323af2

Browse files
committed
Tests: Guard REST context tests against empty endpoints.
Assert that the `endpoints` list is not empty before checking that each endpoint omits the `context` argument. This prevents the block pattern categories, edit site export, and URL details tests from passing without running their loop assertions. Follow-up to [64048], [64049], and [64050]. Developed in: WordPress#13948 Props shailu25. See #40538. git-svn-id: https://develop.svn.wordpress.org/trunk@64077 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f7616f3 commit 8323af2

3 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public function test_context_param() {
194194
$data = $response->get_data();
195195

196196
$this->assertSame( 200, $response->get_status() );
197+
$this->assertNotEmpty( $data['endpoints'] );
197198
foreach ( $data['endpoints'] as $endpoint ) {
198199
$this->assertArrayNotHasKey( 'context', $endpoint['args'] );
199200
}

‎tests/phpunit/tests/rest-api/wpRestEditSiteExportController.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function test_context_param() {
103103
$data = $response->get_data();
104104

105105
$this->assertSame( 200, $response->get_status() );
106+
$this->assertNotEmpty( $data['endpoints'] );
106107
foreach ( $data['endpoints'] as $endpoint ) {
107108
$this->assertArrayNotHasKey( 'context', $endpoint['args'] );
108109
}

‎tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ public function test_context_param() {
10631063
$data = $response->get_data();
10641064

10651065
$this->assertSame( 200, $response->get_status() );
1066+
$this->assertNotEmpty( $data['endpoints'] );
10661067
foreach ( $data['endpoints'] as $endpoint ) {
10671068
$this->assertArrayNotHasKey( 'context', $endpoint['args'] );
10681069
}

0 commit comments

Comments
 (0)