Skip to content

Commit

Permalink
test: add rest schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhooks committed Mar 27, 2023
1 parent f4682e8 commit bb0d296
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions tests/phpunit/tests/rest-api/test-notification-controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Unit tests covering WP_REST_Notification_Controller functionality.
*/
class WP_Test_REST_Notification_Controller extends WP_Test_REST_Post_Type_Controller_Testcase {
public function test_register_routes() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_context_param() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_get_items() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_get_item() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_create_item() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_update_item() {
$this->markTestSkipped( 'TODO Implement' );

}
public function test_delete_item() {
$this->assert( true );
}
public function test_prepare_item() {
$this->markTestSkipped( 'TODO Implement' );
}

public function test_registered_query_params() {
$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/notifications' );
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$keys = array_keys( $data['endpoints'][0]['args'] );
sort( $keys );
$this->assertSame(
array(
'channel',
'offset',
'order',
'orderby',
'page',
'per_page',
'search',
'status',
),
$keys
);
}

public function test_get_item_schema() {
$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/notifications' );
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
// $this->assertCount( 14, $properties );
$this->assertArrayHasKey( 'channel_id', $properties );
$this->assertArrayHasKey( 'context', $properties );
$this->assertArrayHasKey( 'created_at', $properties );
$this->assertArrayHasKey( 'dismissed_at', $properties );
$this->assertArrayHasKey( 'expires_at', $properties );
$this->assertArrayHasKey( 'message', $properties );
// $this->assertArrayHasKey( 'message_key', $properties );
$this->assertArrayHasKey( 'meta', $properties );
$this->assertArrayHasKey( 'severity', $properties );
$this->assertArrayHasKey( 'status', $properties );
$this->assertArrayHasKey( 'title', $properties );
// $this->assertArrayHasKey( 'title_key', $properties );
}
}

0 comments on commit bb0d296

Please sign in to comment.