Merge pull request #187 from woocommerce/release-1.0.8-prep
Release 1.0.8 prep
This commit is contained in:
commit
0756027c66
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "woocommerce-rest-api",
|
||||
"title": "WooCommerce REST API",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.8",
|
||||
"homepage": "https://woocommerce.com/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -419,9 +419,9 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
$images[] = array(
|
||||
'id' => 0,
|
||||
'date_created' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now.
|
||||
'date_created_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ), // Default to now.
|
||||
'date_created_gmt' => wc_rest_prepare_date_response( time() ), // Default to now.
|
||||
'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ),
|
||||
'date_modified_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ),
|
||||
'date_modified_gmt' => wc_rest_prepare_date_response( time() ),
|
||||
'src' => wc_placeholder_img_src(),
|
||||
'name' => __( 'Placeholder', 'woocommerce-rest-api' ),
|
||||
'alt' => __( 'Placeholder', 'woocommerce-rest-api' ),
|
||||
|
@ -2115,7 +2115,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
|
|||
'default' => 'any',
|
||||
'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce-rest-api' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_merge( array( 'any', 'future' ), array_keys( get_post_statuses() ) ),
|
||||
'enum' => array_merge( array( 'any', 'future', 'trash' ), array_keys( get_post_statuses() ) ),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ class Package {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1.0.7';
|
||||
const VERSION = '1.0.8';
|
||||
|
||||
/**
|
||||
* Init the package - load the REST API Server class.
|
||||
|
|
|
@ -113,11 +113,11 @@ class Bootstrap {
|
|||
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
|
||||
|
||||
// WooCommerce Core Testing Framework.
|
||||
require_once $this->wc_tests_dir . '/framework/class-wc-unit-test-factory.php';
|
||||
require_once $this->wc_tests_dir . '/framework/vendor/class-wp-test-spy-rest-server.php';
|
||||
require_once $this->wc_tests_dir . '/includes/wp-http-testcase.php';
|
||||
require_once $this->wc_tests_dir . '/framework/class-wc-unit-test-case.php';
|
||||
require_once $this->wc_tests_dir . '/framework/class-wc-rest-unit-test-case.php';
|
||||
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-unit-test-factory.php';
|
||||
require_once $this->wc_tests_dir . '/legacy/framework/vendor/class-wp-test-spy-rest-server.php';
|
||||
require_once $this->wc_tests_dir . '/legacy/includes/wp-http-testcase.php';
|
||||
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-unit-test-case.php';
|
||||
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-rest-unit-test-case.php';
|
||||
|
||||
require_once $this->tests_dir . '/Helpers/AdminNotesHelper.php';
|
||||
require_once $this->tests_dir . '/Helpers/CouponHelper.php';
|
||||
|
|
|
@ -55,7 +55,7 @@ class WC_Tests_API_Shipping_Zones_V2 extends WC_REST_Unit_Test_Case {
|
|||
public function test_register_routes() {
|
||||
$routes = $this->server->get_routes();
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d-]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d]+)/locations', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d]+)', $routes );
|
||||
|
|
|
@ -82,11 +82,11 @@ class WC_Tests_API_Functions extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_wc_rest_upload_image_from_url_should_return_error_when_invalid_image_is_passed() {
|
||||
// empty file.
|
||||
$expected_error_message = 'Invalid image: File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.';
|
||||
$expected_error_message = 'Invalid image: File is empty.';
|
||||
$result = wc_rest_upload_image_from_url( 'http://somedomain.com/invalid-image-1.png' );
|
||||
|
||||
$this->assertWPError( $result );
|
||||
$this->assertEquals( $expected_error_message, $result->get_error_message() );
|
||||
$this->assertStringStartsWith( $expected_error_message, $result->get_error_message() );
|
||||
|
||||
// unsupported mime type.
|
||||
$expected_error_message = 'Invalid image: Sorry, this file type is not permitted for security reasons.';
|
||||
|
|
|
@ -58,6 +58,59 @@ class WC_Tests_API_Product extends WC_REST_Unit_Test_Case {
|
|||
$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting trashed products.
|
||||
*/
|
||||
public function test_get_trashed_products() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
$data_store->delete( $product );
|
||||
$request = new WP_REST_Request( 'GET', '/wc/v3/products' );
|
||||
$request->set_query_params( array( 'status' => 'trash' ) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$products = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 1, count( $products ) );
|
||||
$this->assertEquals( $product->get_name(), $products[0]['name'] );
|
||||
$this->assertEquals( $product->get_id(), $products[0]['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trashed products should not be returned by default.
|
||||
*/
|
||||
public function test_get_trashed_products_not_returned_by_default() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
$data_store->delete( $product );
|
||||
|
||||
$response = $this->server->dispatch(
|
||||
new WP_REST_Request( 'GET', '/wc/v3/products' )
|
||||
);
|
||||
$products = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 0, count( $products ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trashed product can be fetched directly.
|
||||
*/
|
||||
public function test_get_trashed_products_returned_by_id() {
|
||||
wp_set_current_user( $this->user );
|
||||
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
|
||||
$data_store = WC_Data_Store::load( 'product' );
|
||||
$data_store->delete( $product );
|
||||
|
||||
$response = $this->server->dispatch(
|
||||
new WP_REST_Request( 'GET', '/wc/v3/products/' . $product->get_id() )
|
||||
);
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting products without permission.
|
||||
*
|
||||
|
|
|
@ -57,7 +57,7 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
|||
public function test_register_routes() {
|
||||
$routes = $this->server->get_routes();
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d-]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d]+)/locations', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<zone_id>[\d]+)/methods', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d]+)', $routes );
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Description: The WooCommerce core REST API, installed as a feature plugin for development and testing purposes. Requires WooCommerce 3.7+ and PHP 5.3+.
|
||||
* Author: Automattic
|
||||
* Author URI: https://woocommerce.com
|
||||
* Version: 1.0.7
|
||||
* Requires PHP: 5.6
|
||||
* Version: 1.0.8
|
||||
* Requires PHP: 7.0
|
||||
* License: GPLv3
|
||||
*
|
||||
* @package Automattic/WooCommerce/RestApi
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
|
||||
if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue