Merge pull request #21207 from woocommerce/speedup-get-request-url-test

Reduce WC_Tests_Paypal_Gateway_Request::test_request_url() execution time
This commit is contained in:
Claudiu Lodromanean 2018-08-28 13:25:09 -07:00 committed by GitHub
commit b80c6d86fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -25,11 +25,12 @@ class WC_Helper_Product {
* @since 2.3 * @since 2.3
* @return WC_Product_Simple * @return WC_Product_Simple
*/ */
public static function create_simple_product() { public static function create_simple_product( $save = true ) {
$product = new WC_Product_Simple(); $product = new WC_Product_Simple();
$product->set_props( array( $product->set_props( array(
'name' => 'Dummy Product', 'name' => 'Dummy Product',
'regular_price' => 10, 'regular_price' => 10,
'price' => 10,
'sku' => 'DUMMY SKU', 'sku' => 'DUMMY SKU',
'manage_stock' => false, 'manage_stock' => false,
'tax_status' => 'taxable', 'tax_status' => 'taxable',
@ -38,9 +39,13 @@ class WC_Helper_Product {
'stock_status' => 'instock', 'stock_status' => 'instock',
'weight' => '1.1', 'weight' => '1.1',
) ); ) );
$product->save();
return wc_get_product( $product->get_id() ); if ( $save ) {
$product->save();
return wc_get_product( $product->get_id() );
} else {
return $product;
}
} }
/** /**

View File

@ -28,7 +28,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
protected function create_products( $product_count = 30 ) { protected function create_products( $product_count = 30 ) {
$this->products = array(); $this->products = array();
for ( $i = 0; $i < $product_count; $i++ ) { for ( $i = 0; $i < $product_count; $i++ ) {
$product = WC_Helper_Product::create_simple_product(); $product = WC_Helper_Product::create_simple_product( false );
$product->set_name( 'Dummy Product ' . $i ); $product->set_name( 'Dummy Product ' . $i );
$this->products[] = $product; $this->products[] = $product;