Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 0756027

Browse files
authored
Merge pull request #187 from woocommerce/release-1.0.8-prep
Release 1.0.8 prep
2 parents 49162ec + 7c9fd1a commit 0756027

File tree

9 files changed

+70
-17
lines changed

9 files changed

+70
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "woocommerce-rest-api",
33
"title": "WooCommerce REST API",
4-
"version": "1.0.5",
4+
"version": "1.0.8",
55
"homepage": "https://woocommerce.com/",
66
"repository": {
77
"type": "git",

src/Controllers/Version2/class-wc-rest-products-v2-controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ protected function get_images( $product ) {
419419
$images[] = array(
420420
'id' => 0,
421421
'date_created' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now.
422-
'date_created_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ), // Default to now.
422+
'date_created_gmt' => wc_rest_prepare_date_response( time() ), // Default to now.
423423
'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ),
424-
'date_modified_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ),
424+
'date_modified_gmt' => wc_rest_prepare_date_response( time() ),
425425
'src' => wc_placeholder_img_src(),
426426
'name' => __( 'Placeholder', 'woocommerce-rest-api' ),
427427
'alt' => __( 'Placeholder', 'woocommerce-rest-api' ),
@@ -2115,7 +2115,7 @@ public function get_collection_params() {
21152115
'default' => 'any',
21162116
'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce-rest-api' ),
21172117
'type' => 'string',
2118-
'enum' => array_merge( array( 'any', 'future' ), array_keys( get_post_statuses() ) ),
2118+
'enum' => array_merge( array( 'any', 'future', 'trash' ), array_keys( get_post_statuses() ) ),
21192119
'sanitize_callback' => 'sanitize_key',
21202120
'validate_callback' => 'rest_validate_request_arg',
21212121
);

src/Package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Package {
1919
*
2020
* @var string
2121
*/
22-
const VERSION = '1.0.7';
22+
const VERSION = '1.0.8';
2323

2424
/**
2525
* Init the package - load the REST API Server class.

unit-tests/Bootstrap.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ protected function load_framework() {
113113
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
114114

115115
// WooCommerce Core Testing Framework.
116-
require_once $this->wc_tests_dir . '/framework/class-wc-unit-test-factory.php';
117-
require_once $this->wc_tests_dir . '/framework/vendor/class-wp-test-spy-rest-server.php';
118-
require_once $this->wc_tests_dir . '/includes/wp-http-testcase.php';
119-
require_once $this->wc_tests_dir . '/framework/class-wc-unit-test-case.php';
120-
require_once $this->wc_tests_dir . '/framework/class-wc-rest-unit-test-case.php';
116+
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-unit-test-factory.php';
117+
require_once $this->wc_tests_dir . '/legacy/framework/vendor/class-wp-test-spy-rest-server.php';
118+
require_once $this->wc_tests_dir . '/legacy/includes/wp-http-testcase.php';
119+
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-unit-test-case.php';
120+
require_once $this->wc_tests_dir . '/legacy/framework/class-wc-rest-unit-test-case.php';
121121

122122
require_once $this->tests_dir . '/Helpers/AdminNotesHelper.php';
123123
require_once $this->tests_dir . '/Helpers/CouponHelper.php';

unit-tests/Tests/Version2/shipping-zones.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function create_shipping_zone( $name, $order = 0, $locations = array()
5555
public function test_register_routes() {
5656
$routes = $this->server->get_routes();
5757
$this->assertArrayHasKey( '/wc/v2/shipping/zones', $routes );
58-
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d-]+)', $routes );
58+
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d]+)', $routes );
5959
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d]+)/locations', $routes );
6060
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods', $routes );
6161
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d]+)', $routes );

unit-tests/Tests/Version3/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public function test_wc_rest_upload_image_from_url_should_return_error_when_unab
8282
*/
8383
public function test_wc_rest_upload_image_from_url_should_return_error_when_invalid_image_is_passed() {
8484
// empty file.
85-
$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.';
85+
$expected_error_message = 'Invalid image: File is empty.';
8686
$result = wc_rest_upload_image_from_url( 'http://somedomain.com/invalid-image-1.png' );
8787

8888
$this->assertWPError( $result );
89-
$this->assertEquals( $expected_error_message, $result->get_error_message() );
89+
$this->assertStringStartsWith( $expected_error_message, $result->get_error_message() );
9090

9191
// unsupported mime type.
9292
$expected_error_message = 'Invalid image: Sorry, this file type is not permitted for security reasons.';

unit-tests/Tests/Version3/products.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,59 @@ public function test_get_products() {
5858
$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] );
5959
}
6060

61+
/**
62+
* Test getting trashed products.
63+
*/
64+
public function test_get_trashed_products() {
65+
wp_set_current_user( $this->user );
66+
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
67+
$data_store = WC_Data_Store::load( 'product' );
68+
$data_store->delete( $product );
69+
$request = new WP_REST_Request( 'GET', '/wc/v3/products' );
70+
$request->set_query_params( array( 'status' => 'trash' ) );
71+
$response = $this->server->dispatch( $request );
72+
$products = $response->get_data();
73+
74+
$this->assertEquals( 200, $response->get_status() );
75+
$this->assertEquals( 1, count( $products ) );
76+
$this->assertEquals( $product->get_name(), $products[0]['name'] );
77+
$this->assertEquals( $product->get_id(), $products[0]['id'] );
78+
}
79+
80+
/**
81+
* Trashed products should not be returned by default.
82+
*/
83+
public function test_get_trashed_products_not_returned_by_default() {
84+
wp_set_current_user( $this->user );
85+
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
86+
$data_store = WC_Data_Store::load( 'product' );
87+
$data_store->delete( $product );
88+
89+
$response = $this->server->dispatch(
90+
new WP_REST_Request( 'GET', '/wc/v3/products' )
91+
);
92+
$products = $response->get_data();
93+
94+
$this->assertEquals( 200, $response->get_status() );
95+
$this->assertEquals( 0, count( $products ) );
96+
}
97+
98+
/**
99+
* Trashed product can be fetched directly.
100+
*/
101+
public function test_get_trashed_products_returned_by_id() {
102+
wp_set_current_user( $this->user );
103+
$product = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
104+
$data_store = WC_Data_Store::load( 'product' );
105+
$data_store->delete( $product );
106+
107+
$response = $this->server->dispatch(
108+
new WP_REST_Request( 'GET', '/wc/v3/products/' . $product->get_id() )
109+
);
110+
111+
$this->assertEquals( 200, $response->get_status() );
112+
}
113+
61114
/**
62115
* Test getting products without permission.
63116
*

unit-tests/Tests/Version3/shipping-zones.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function create_shipping_zone( $name, $order = 0, $locations = array()
5757
public function test_register_routes() {
5858
$routes = $this->server->get_routes();
5959
$this->assertArrayHasKey( '/wc/v3/shipping/zones', $routes );
60-
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d-]+)', $routes );
60+
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d]+)', $routes );
6161
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<id>[\d]+)/locations', $routes );
6262
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<zone_id>[\d]+)/methods', $routes );
6363
$this->assertArrayHasKey( '/wc/v3/shipping/zones/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d]+)', $routes );

woocommerce-rest-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Description: The WooCommerce core REST API, installed as a feature plugin for development and testing purposes. Requires WooCommerce 3.7+ and PHP 5.3+.
66
* Author: Automattic
77
* Author URI: https://woocommerce.com
8-
* Version: 1.0.7
9-
* Requires PHP: 5.6
8+
* Version: 1.0.8
9+
* Requires PHP: 7.0
1010
* License: GPLv3
1111
*
1212
* @package Automattic/WooCommerce/RestApi
@@ -15,7 +15,7 @@
1515

1616
defined( 'ABSPATH' ) || exit;
1717

18-
if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
18+
if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) {
1919
return;
2020
}
2121

0 commit comments

Comments
 (0)