2018-12-12 13:35:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Product Reviews REST API Test
|
|
|
|
*
|
2020-08-11 19:18:47 +00:00
|
|
|
* @package WooCommerce\Admin\Tests\API
|
2018-12-12 13:35:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC Tests API Product Reviews
|
|
|
|
*/
|
|
|
|
class WC_Tests_API_Product_Reviews extends WC_REST_Unit_Test_Case {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Endpoints.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-11-12 18:15:55 +00:00
|
|
|
protected $endpoint = '/wc-analytics/products/reviews';
|
2018-12-12 13:35:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup test data. Called before every test.
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2019-02-14 23:19:22 +00:00
|
|
|
$this->user = $this->factory->user->create(
|
2018-12-12 13:35:56 +00:00
|
|
|
array(
|
|
|
|
'role' => 'administrator',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test product reviews shows product field as embeddable.
|
|
|
|
*/
|
|
|
|
public function test_product_review_embed() {
|
|
|
|
wp_set_current_user( $this->user );
|
2019-02-14 23:19:22 +00:00
|
|
|
$product = WC_Helper_Product::create_simple_product();
|
2018-12-12 13:35:56 +00:00
|
|
|
WC_Helper_Product::create_product_review( $product->get_id() );
|
|
|
|
|
2019-11-12 18:15:55 +00:00
|
|
|
$request = new WP_REST_Request( 'GET', '/wc-analytics/products/reviews' );
|
2018-12-12 13:35:56 +00:00
|
|
|
|
|
|
|
$response = $this->server->dispatch( $request );
|
|
|
|
$data = $response->get_data();
|
|
|
|
|
|
|
|
$this->assertTrue( $data[0]['_links']['up'][0]['embeddable'] );
|
|
|
|
|
|
|
|
$product->delete( true );
|
|
|
|
}
|
|
|
|
}
|