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';
$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';
$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';
$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 );
$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_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' ) );
$expected_parent = '';
$parent_id = $product->get_parent_id();
$parent_id = $product->get_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();
}
$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
*/
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(
array(
'simple',
@ -433,40 +439,40 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'menu_order' => 3,
),
array(
'type' => 'variation',
'sku' => '',
'name' => '',
'featured' => '',
'catalog_visibility' => 'visible',
'short_description' => '',
'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_to' => null,
'tax_status' => 'taxable',
'tax_class' => 'standard',
'stock_status' => 'instock',
'stock_quantity' => 6,
'backorders' => 'no',
'sold_individually' => '',
'weight' => 1.0,
'length' => 2.0,
'width' => 25.0,
'height' => 55.0,
'reviews_allowed' => '',
'purchase_note' => '',
'sale_price' => '',
'regular_price' => '20',
'shipping_class_id' => 0,
'download_limit' => 0,
'download_expiry' => 0,
'product_url' => '',
'button_text' => '',
'status' => 'publish',
'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'virtual' => false,
'downloadable' => false,
'manage_stock' => true,
'raw_attributes' => array(
'type' => 'variation',
'sku' => '',
'name' => '',
'featured' => '',
'catalog_visibility' => 'visible',
'short_description' => '',
'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_to' => null,
'tax_status' => 'taxable',
'tax_class' => 'standard',
'stock_status' => 'instock',
'stock_quantity' => 6,
'backorders' => 'no',
'sold_individually' => '',
'weight' => 1.0,
'length' => 2.0,
'width' => 25.0,
'height' => 55.0,
'reviews_allowed' => '',
'purchase_note' => '',
'sale_price' => '',
'regular_price' => '20',
'shipping_class_id' => 0,
'download_limit' => 0,
'download_expiry' => 0,
'product_url' => '',
'button_text' => '',
'status' => 'publish',
'raw_image_id' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
'virtual' => false,
'downloadable' => false,
'manage_stock' => true,
'raw_attributes' => array(
array(
'name' => 'Color',
),
@ -475,7 +481,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size',
),
),
'menu_order' => 1,
'menu_order' => 1,
),
array(
'type' => 'variation',
@ -520,7 +526,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
'name' => 'Size',
),
),
'menu_order' => 2,
'menu_order' => 2,
),
array(
'type' => 'grouped',
@ -571,11 +577,13 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
$this->assertEquals( $items, $parsed_data );
// Remove temporary products.
$temp_products = get_posts( array(
'post_status' => 'importing',
'post_type' => 'product',
'fields' => 'ids',
) );
$temp_products = get_posts(
array(
'post_status' => 'importing',
'post_type' => 'product',
'fields' => 'ids',
)
);
foreach ( $temp_products as $id ) {
wp_delete_post( $id, true );
}

View File

@ -29,7 +29,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$expected = array();
foreach ( $item->get_meta_data() as $metadata ) {
$expected[ $metadata->id ] = array(
'key' => $metadata->key,
'key' => $metadata->key,
'label' => wc_attribute_label( $metadata->key, null ),
'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 );
$expected = array( 'regularkey' => '1', 'category' => 'Testing Categories' );
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' );
$expected = array(
'regularkey' => '1',
'category' => 'Testing Categories',
);
$actual = wp_list_pluck( $meta->get_formatted(), 'value', 'key' );
$this->assertEquals( $expected, $actual );
// Clean up.
@ -84,7 +87,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
$meta = new WC_Order_Item_Meta( $item );
$expected = "regularkey: 1, \ncategory: Testing Categories";
$flat = $meta->display( true, true );
$flat = $meta->display( true, true );
$this->assertEquals( $expected, $flat );
$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.
$response = WC_Privacy::customer_data_exporter( 'test1@test.com', 1 );
$this->assertTrue( $response['done'] );
$this->assertEquals( array(
$this->assertEquals(
array(
'group_id' => 'woocommerce_customer',
'group_label' => 'Customer Data',
'item_id' => 'user',
'data' => array(
array(
'name' => 'Billing Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Billing Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Billing City',
'value' => 'Philadelphia',
),
array(
'name' => 'Billing Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Billing State',
'value' => 'PA',
),
array(
'name' => 'Billing Country',
'value' => 'US',
),
array(
'name' => 'Email Address',
'value' => 'customer1@test.com',
),
array(
'name' => 'Shipping Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Shipping Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Shipping City',
'value' => 'Philadelphia',
),
array(
'name' => 'Shipping Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Shipping State',
'value' => 'PA',
),
array(
'name' => 'Shipping Country',
'value' => 'US',
array(
'group_id' => 'woocommerce_customer',
'group_label' => 'Customer Data',
'item_id' => 'user',
'data' => array(
array(
'name' => 'Billing Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Billing Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Billing City',
'value' => 'Philadelphia',
),
array(
'name' => 'Billing Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Billing State',
'value' => 'PA',
),
array(
'name' => 'Billing Country',
'value' => 'US',
),
array(
'name' => 'Email Address',
'value' => 'customer1@test.com',
),
array(
'name' => 'Shipping Address 1',
'value' => '123 South Street',
),
array(
'name' => 'Shipping Address 2',
'value' => 'Apt 1',
),
array(
'name' => 'Shipping City',
'value' => 'Philadelphia',
),
array(
'name' => 'Shipping Postal/Zip Code',
'value' => '19123',
),
array(
'name' => 'Shipping State',
'value' => 'PA',
),
array(
'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 );
}
$tax_rate = array(
$tax_rate = array(
'tax_rate_country' => '',
'tax_rate_state' => '',
'tax_rate' => '20.0000',
@ -54,7 +54,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
$product = WC_Helper_Product::create_simple_product();
$product2 = WC_Helper_Product::create_simple_product();
// Variations with parent tax class.
$product3 = WC_Helper_Product::create_variation_product();
$product3 = WC_Helper_Product::create_variation_product();
$variations = $product3->get_available_variations();
// 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()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
$coupon = new WC_Coupon;
$coupon = new WC_Coupon();
$coupon->set_code( 'test-coupon-10' );
$coupon->set_amount( 10 );
$coupon->set_discount_type( 'percent' );
@ -131,19 +131,22 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
* Test get and set items.
*/
public function test_get_totals() {
$this->assertEquals( array(
'fees_total' => 40.00,
'fees_total_tax' => 6.00,
'items_subtotal' => 40.00,
'items_subtotal_tax' => 8.00,
'items_total' => 36.00,
'items_total_tax' => 7.20,
'total' => 101.20,
'shipping_total' => 10,
'shipping_tax_total' => 2,
'discounts_total' => 4.00,
'discounts_tax_total' => 0.80,
), $this->totals->get_totals() );
$this->assertEquals(
array(
'fees_total' => 40.00,
'fees_total_tax' => 6.00,
'items_subtotal' => 40.00,
'items_subtotal_tax' => 8.00,
'items_total' => 36.00,
'items_total_tax' => 7.20,
'total' => 101.20,
'shipping_total' => 10,
'shipping_tax_total' => 2,
'discounts_total' => 4.00,
'discounts_tax_total' => 0.80,
),
$this->totals->get_totals()
);
}
/**