Fix performance-indicators/allowed schema.

This commit is contained in:
Justin Shreve 2019-01-21 12:28:32 -05:00
parent 3ac97e00c4
commit 1f8caf106e
2 changed files with 18 additions and 1 deletions

View File

@ -458,7 +458,7 @@ class WC_Admin_REST_Reports_Performance_Indicators_Controller extends WC_REST_Re
$schema = $this->get_public_item_schema(); $schema = $this->get_public_item_schema();
unset( $schema['properties']['value'] ); unset( $schema['properties']['value'] );
unset( $schema['properties']['format'] ); unset( $schema['properties']['format'] );
return $sceham; return $schema;
} }
/** /**

View File

@ -161,4 +161,21 @@ class WC_Tests_API_Reports_Performance_Indicators extends WC_REST_Unit_Test_Case
$this->assertArrayHasKey( 'format', $properties ); $this->assertArrayHasKey( 'format', $properties );
$this->assertArrayHasKey( 'value', $properties ); $this->assertArrayHasKey( 'value', $properties );
} }
/**
* Test schema for /allowed indicators endpoint.
*/
public function test_indicators_schema_allowed() {
wp_set_current_user( $this->user );
$request = new WP_REST_Request( 'OPTIONS', $this->endpoint . '/allowed' );
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
$this->assertEquals( 3, count( $properties ) );
$this->assertArrayHasKey( 'stat', $properties );
$this->assertArrayHasKey( 'chart', $properties );
$this->assertArrayHasKey( 'label', $properties );
}
} }