PHPCS fixes

This commit is contained in:
Rodrigo Primo 2018-04-20 14:53:06 -03:00
parent c115832c4a
commit c7c82a2335
5 changed files with 153 additions and 124 deletions

View File

@ -69,12 +69,24 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$expected = 'cat1, cat2, cat3'; $expected = 'cat1, cat2, cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) ); $this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
wp_insert_category( array( 'cat_ID' => $term2, 'cat_name' => 'cat2', 'category_parent' => $term1 ) ); wp_insert_category(
array(
'cat_ID' => $term2,
'cat_name' => 'cat2',
'category_parent' => $term1,
)
);
$expected = 'cat1, cat1 > cat2, cat3'; $expected = 'cat1, cat1 > cat2, cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) ); $this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
wp_insert_category( array( 'cat_ID' => $term3, 'cat_name' => 'cat3', 'category_parent' => $term2 ) ); wp_insert_category(
array(
'cat_ID' => $term3,
'cat_name' => 'cat3',
'category_parent' => $term2,
)
);
$expected = 'cat1, cat1 > cat2, cat1 > cat2 > cat3'; $expected = 'cat1, cat1 > cat2, cat1 > cat2 > cat3';
$this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) ); $this->assertEquals( $expected, $exporter->format_term_ids( array( $term1, $term2, $term3 ), 'category' ) );
} }
@ -96,7 +108,7 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$product->set_width( 1 ); $product->set_width( 1 );
$sale_start = time(); $sale_start = time();
$sale_end = $sale_start + DAY_IN_SECONDS; $sale_end = $sale_start + DAY_IN_SECONDS;
$product->set_date_on_sale_from( $sale_start ); $product->set_date_on_sale_from( $sale_start );
$product->set_date_on_sale_to( $sale_end ); $product->set_date_on_sale_to( $sale_end );
@ -136,9 +148,9 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
$this->assertContains( $row['backorders'], array( 1, 0, 'notify' ) ); $this->assertContains( $row['backorders'], array( 1, 0, 'notify' ) );
$expected_parent = ''; $expected_parent = '';
$parent_id = $product->get_parent_id(); $parent_id = $product->get_parent_id();
if ( $parent_id ) { if ( $parent_id ) {
$parent = wc_get_product( $parent_id ); $parent = wc_get_product( $parent_id );
$expected_parent = $parent->get_sku() ? $parent->get_sku() : 'id:' . $parent->get_id(); $expected_parent = $parent->get_sku() ? $parent->get_sku() : 'id:' . $parent->get_id();
} }
$this->assertEquals( $expected_parent, $row['parent_id'] ); $this->assertEquals( $expected_parent, $row['parent_id'] );

View File

@ -135,7 +135,13 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
* @since 3.1.0 * @since 3.1.0
*/ */
public function test_get_raw_data() { public function test_get_raw_data() {
$importer = new WC_Product_CSV_Importer( $this->csv_file, array( 'parse' => false, 'lines' => 2 ) ); $importer = new WC_Product_CSV_Importer(
$this->csv_file,
array(
'parse' => false,
'lines' => 2,
)
);
$items = array( $items = array(
array( array(
'simple', 'simple',
@ -433,40 +439,40 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'menu_order' => 3, 'menu_order' => 3,
), ),
array( array(
'type' => 'variation', 'type' => 'variation',
'sku' => '', 'sku' => '',
'name' => '', 'name' => '',
'featured' => '', 'featured' => '',
'catalog_visibility' => 'visible', 'catalog_visibility' => 'visible',
'short_description' => '', 'short_description' => '',
'description' => 'Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.', 'description' => 'Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.',
'date_on_sale_from' => null, 'date_on_sale_from' => null,
'date_on_sale_to' => null, 'date_on_sale_to' => null,
'tax_status' => 'taxable', 'tax_status' => 'taxable',
'tax_class' => 'standard', 'tax_class' => 'standard',
'stock_status' => 'instock', 'stock_status' => 'instock',
'stock_quantity' => 6, 'stock_quantity' => 6,
'backorders' => 'no', 'backorders' => 'no',
'sold_individually' => '', 'sold_individually' => '',
'weight' => 1.0, 'weight' => 1.0,
'length' => 2.0, 'length' => 2.0,
'width' => 25.0, 'width' => 25.0,
'height' => 55.0, 'height' => 55.0,
'reviews_allowed' => '', 'reviews_allowed' => '',
'purchase_note' => '', 'purchase_note' => '',
'sale_price' => '', 'sale_price' => '',
'regular_price' => '20', 'regular_price' => '20',
'shipping_class_id' => 0, 'shipping_class_id' => 0,
'download_limit' => 0, 'download_limit' => 0,
'download_expiry' => 0, 'download_expiry' => 0,
'product_url' => '', 'product_url' => '',
'button_text' => '', 'button_text' => '',
'status' => 'publish', 'status' => 'publish',
'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg', 'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'virtual' => false, 'virtual' => false,
'downloadable' => false, 'downloadable' => false,
'manage_stock' => true, 'manage_stock' => true,
'raw_attributes' => array( 'raw_attributes' => array(
array( array(
'name' => 'Color', 'name' => 'Color',
), ),
@ -475,7 +481,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size', 'name' => 'Size',
), ),
), ),
'menu_order' => 1, 'menu_order' => 1,
), ),
array( array(
'type' => 'variation', 'type' => 'variation',
@ -520,7 +526,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size', 'name' => 'Size',
), ),
), ),
'menu_order' => 2, 'menu_order' => 2,
), ),
array( array(
'type' => 'grouped', 'type' => 'grouped',
@ -571,11 +577,13 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
$this->assertEquals( $items, $parsed_data ); $this->assertEquals( $items, $parsed_data );
// Remove temporary products. // Remove temporary products.
$temp_products = get_posts( array( $temp_products = get_posts(
'post_status' => 'importing', array(
'post_type' => 'product', 'post_status' => 'importing',
'fields' => 'ids', 'post_type' => 'product',
) ); 'fields' => 'ids',
)
);
foreach ( $temp_products as $id ) { foreach ( $temp_products as $id ) {
wp_delete_post( $id, true ); wp_delete_post( $id, true );
} }

View File

@ -29,7 +29,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$expected = array(); $expected = array();
foreach ( $item->get_meta_data() as $metadata ) { foreach ( $item->get_meta_data() as $metadata ) {
$expected[ $metadata->id ] = array( $expected[ $metadata->id ] = array(
'key' => $metadata->key, 'key' => $metadata->key,
'label' => wc_attribute_label( $metadata->key, null ), 'label' => wc_attribute_label( $metadata->key, null ),
'value' => $metadata->value, 'value' => $metadata->value,
); );
@ -60,8 +60,11 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$meta = new WC_Order_Item_Meta( $item ); $meta = new WC_Order_Item_Meta( $item );
$expected = array( 'regularkey' => '1', 'category' => 'Testing Categories' ); $expected = array(
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' ); 'regularkey' => '1',
'category' => 'Testing Categories',
);
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' );
$this->assertEquals( $expected, $actual ); $this->assertEquals( $expected, $actual );
// Clean up. // Clean up.
@ -84,7 +87,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$meta = new WC_Order_Item_Meta( $item ); $meta = new WC_Order_Item_Meta( $item );
$expected = "regularkey: 1, \ncategory: Testing Categories"; $expected = "regularkey: 1, \ncategory: Testing Categories";
$flat = $meta->display( true, true ); $flat = $meta->display( true, true );
$this->assertEquals( $expected, $flat ); $this->assertEquals( $expected, $flat );
$not_flat = $meta->display( false, true ); $not_flat = $meta->display( false, true );

View File

@ -74,67 +74,70 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
// Do a test export and check response. // Do a test export and check response.
$response = WC_Privacy::customer_data_exporter( 'test1@test.com', 1 ); $response = WC_Privacy::customer_data_exporter( 'test1@test.com', 1 );
$this->assertTrue( $response['done'] ); $this->assertTrue( $response['done'] );
$this->assertEquals( array( $this->assertEquals(
array( array(
'group_id' => 'woocommerce_customer', array(
'group_label' => 'Customer Data', 'group_id' => 'woocommerce_customer',
'item_id' => 'user', 'group_label' => 'Customer Data',
'data' => array( 'item_id' => 'user',
array( 'data' => array(
'name' => 'Billing Address 1', array(
'value' => '123 South Street', 'name' => 'Billing Address 1',
), 'value' => '123 South Street',
array( ),
'name' => 'Billing Address 2', array(
'value' => 'Apt 1', 'name' => 'Billing Address 2',
), 'value' => 'Apt 1',
array( ),
'name' => 'Billing City', array(
'value' => 'Philadelphia', 'name' => 'Billing City',
), 'value' => 'Philadelphia',
array( ),
'name' => 'Billing Postal/Zip Code', array(
'value' => '19123', 'name' => 'Billing Postal/Zip Code',
), 'value' => '19123',
array( ),
'name' => 'Billing State', array(
'value' => 'PA', 'name' => 'Billing State',
), 'value' => 'PA',
array( ),
'name' => 'Billing Country', array(
'value' => 'US', 'name' => 'Billing Country',
), 'value' => 'US',
array( ),
'name' => 'Email Address', array(
'value' => 'customer1@test.com', 'name' => 'Email Address',
), 'value' => 'customer1@test.com',
array( ),
'name' => 'Shipping Address 1', array(
'value' => '123 South Street', 'name' => 'Shipping Address 1',
), 'value' => '123 South Street',
array( ),
'name' => 'Shipping Address 2', array(
'value' => 'Apt 1', 'name' => 'Shipping Address 2',
), 'value' => 'Apt 1',
array( ),
'name' => 'Shipping City', array(
'value' => 'Philadelphia', 'name' => 'Shipping City',
), 'value' => 'Philadelphia',
array( ),
'name' => 'Shipping Postal/Zip Code', array(
'value' => '19123', 'name' => 'Shipping Postal/Zip Code',
), 'value' => '19123',
array( ),
'name' => 'Shipping State', array(
'value' => 'PA', 'name' => 'Shipping State',
), 'value' => 'PA',
array( ),
'name' => 'Shipping Country', array(
'value' => 'US', 'name' => 'Shipping Country',
'value' => 'US',
),
), ),
), ),
), ),
), $response['data'] ); $response['data']
);
} }
/** /**

View File

@ -34,7 +34,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
define( 'WOOCOMMERCE_CHECKOUT', 1 ); define( 'WOOCOMMERCE_CHECKOUT', 1 );
} }
$tax_rate = array( $tax_rate = array(
'tax_rate_country' => '', 'tax_rate_country' => '',
'tax_rate_state' => '', 'tax_rate_state' => '',
'tax_rate' => '20.0000', 'tax_rate' => '20.0000',
@ -54,7 +54,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
$product = WC_Helper_Product::create_simple_product(); $product = WC_Helper_Product::create_simple_product();
$product2 = WC_Helper_Product::create_simple_product(); $product2 = WC_Helper_Product::create_simple_product();
// Variations with parent tax class. // Variations with parent tax class.
$product3 = WC_Helper_Product::create_variation_product(); $product3 = WC_Helper_Product::create_variation_product();
$variations = $product3->get_available_variations(); $variations = $product3->get_available_variations();
// Update product3 so that each variation has the parent tax class. // Update product3 so that each variation has the parent tax class.
@ -67,7 +67,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
WC_Helper_Shipping::create_simple_flat_rate(); WC_Helper_Shipping::create_simple_flat_rate();
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) ); WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
$coupon = new WC_Coupon; $coupon = new WC_Coupon();
$coupon->set_code( 'test-coupon-10' ); $coupon->set_code( 'test-coupon-10' );
$coupon->set_amount( 10 ); $coupon->set_amount( 10 );
$coupon->set_discount_type( 'percent' ); $coupon->set_discount_type( 'percent' );
@ -131,19 +131,22 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
* Test get and set items. * Test get and set items.
*/ */
public function test_get_totals() { public function test_get_totals() {
$this->assertEquals( array( $this->assertEquals(
'fees_total' => 40.00, array(
'fees_total_tax' => 6.00, 'fees_total' => 40.00,
'items_subtotal' => 40.00, 'fees_total_tax' => 6.00,
'items_subtotal_tax' => 8.00, 'items_subtotal' => 40.00,
'items_total' => 36.00, 'items_subtotal_tax' => 8.00,
'items_total_tax' => 7.20, 'items_total' => 36.00,
'total' => 101.20, 'items_total_tax' => 7.20,
'shipping_total' => 10, 'total' => 101.20,
'shipping_tax_total' => 2, 'shipping_total' => 10,
'discounts_total' => 4.00, 'shipping_tax_total' => 2,
'discounts_tax_total' => 0.80, 'discounts_total' => 4.00,
), $this->totals->get_totals() ); 'discounts_tax_total' => 0.80,
),
$this->totals->get_totals()
);
} }
/** /**