2018-12-12 13:35:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Product Reviews REST API Test
|
|
|
|
*
|
|
|
|
* @package WooCommerce Admin\Tests\API
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC Tests API Product Reviews
|
|
|
|
*/
|
|
|
|
class WC_Tests_API_Product_Reviews extends WC_REST_Unit_Test_Case {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Endpoints.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-01-18 02:52:58 +00:00
|
|
|
protected $endpoint = '/wc/v4/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-01-18 02:52:58 +00:00
|
|
|
$request = new WP_REST_Request( 'GET', '/wc/v4/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 );
|
|
|
|
}
|
|
|
|
}
|