Fixed unit tests and coding standards

This commit is contained in:
Claudio Sanches 2019-05-20 17:27:25 -03:00
parent a2301dc0cb
commit 8af5117bf4
1 changed files with 45 additions and 41 deletions

View File

@ -1,10 +1,13 @@
<?php
/**
* Class WC_Shortcode_Products.
* Test WC_Shortcode_Products
*
* @package WooCommerce\Tests\Shortcodes
*/
/**
* Class WC_Test_Shortcode_Products.
*/
class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
/**
@ -80,8 +83,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '-1',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
);
$this->assertEquals( $expected, $shortcode->get_query_args() );
@ -101,8 +104,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'ID',
'order' => 'DESC',
'posts_per_page' => '-1',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
);
$this->assertEquals( $expected2, $shortcode2->get_query_args() );
@ -121,8 +124,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '-1',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'post__in' => array( '1', '2', '3' ),
'fields' => 'ids',
);
@ -154,8 +157,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '12',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
);
$expected4['tax_query'][] = array(
@ -188,8 +191,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '12',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
);
$expected4_id['tax_query'][] = array(
@ -222,8 +225,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'date ID',
'order' => 'DESC',
'posts_per_page' => '12',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
);
@ -245,8 +248,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '1',
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'p' => '1',
'fields' => 'ids',
);
@ -273,8 +276,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() ),
'fields' => 'ids',
);
@ -299,9 +302,9 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_key' => 'total_sales',
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'meta_key' => 'total_sales', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
'fields' => 'ids',
);
@ -324,12 +327,13 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
'meta_key' => '_wc_average_rating', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
);
$this->assertEquals( $expected9, $shortcode9->get_query_args() );
@ -354,8 +358,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'date ID',
'order' => 'DESC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => array_merge(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array_merge( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
$tax_query,
array(
array(
@ -392,8 +396,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => array_merge(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array_merge( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
$tax_query,
array(
array(
@ -429,8 +433,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 12,
'meta_query' => $meta_query,
'tax_query' => array_merge(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array_merge( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
$tax_query,
array(
array(
@ -460,8 +464,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query,
'tax_query' => array(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
array(
'taxonomy' => 'product_visibility',
'terms' => array( 'exclude-from-catalog', 'exclude-from-search' ),
@ -488,8 +492,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query,
'tax_query' => array(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
array(
'taxonomy' => 'product_visibility',
'terms' => 'exclude-from-search',
@ -523,8 +527,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query,
'tax_query' => array(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
array(
'taxonomy' => 'product_visibility',
'terms' => 'exclude-from-catalog',
@ -560,8 +564,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query,
'tax_query' => array_merge(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array_merge( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
$tax_query,
array(
array(
@ -593,8 +597,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query,
'tax_query' => array_merge(
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => array_merge( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
$tax_query,
array(
array(