diff --git a/includes/model/class-coupon.php b/includes/model/class-coupon.php index b99cd111..c8a5d15c 100644 --- a/includes/model/class-coupon.php +++ b/includes/model/class-coupon.php @@ -23,7 +23,7 @@ class Coupon extends Crud_CPT { 'isPrivate', 'isPublic', 'id', - 'couponId', + 'databaseId', ); parent::__construct( $allowed_restricted_fields, 'shop_coupon', $id ); @@ -64,8 +64,8 @@ class Coupon extends Crud_CPT { 'id' => function() { return ! empty( $this->data->get_id() ) ? Relay::toGlobalId( 'shop_coupon', $this->data->get_id() ) : null; }, - 'couponId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID; }, 'code' => function() { return ! empty( $this->data->get_code() ) ? $this->data->get_code() : null; diff --git a/includes/model/class-customer.php b/includes/model/class-customer.php index 6e1f0dd4..0bb7d945 100644 --- a/includes/model/class-customer.php +++ b/includes/model/class-customer.php @@ -65,8 +65,8 @@ class Customer extends Model { ? Relay::toGlobalId( 'customer', $this->data->get_id() ) : 'new_customer'; }, - 'customerId' => function() { - return ( ! empty( $this->data->get_id() ) ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID; }, 'isVatExempt' => function() { return ! is_null( $this->data->get_is_vat_exempt() ) ? $this->data->get_is_vat_exempt() : null; diff --git a/includes/model/class-order-item.php b/includes/model/class-order-item.php index 45017ade..ca467cd3 100644 --- a/includes/model/class-order-item.php +++ b/includes/model/class-order-item.php @@ -47,7 +47,7 @@ class Order_Item extends Model { 'isPrivate', 'isPublic', 'id', - 'orderItemId', + 'databaseId', ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound @@ -73,16 +73,16 @@ class Order_Item extends Model { protected function init() { if ( empty( $this->fields ) ) { $this->fields = array( - 'ID' => function() { + 'ID' => function() { return $this->data->get_id(); }, - 'itemId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID; }, - 'orderId' => function() { + 'orderId' => function() { return ! empty( $this->data->get_order_id() ) ? $this->data->get_order_id() : null; }, - 'type' => function() { + 'type' => function() { return ! empty( $this->data->get_type() ) ? $this->data->get_type() : null; }, ); @@ -193,10 +193,10 @@ class Order_Item extends Model { return ! empty( $this->data->get_tax_total() ) ? $this->data->get_tax_total() : null; }, 'shippingTaxTotal' => function() { - return ! empty( $this->data->get_shipping_tax_total() ) ? $this->data->get_shipping_tax_total() : null; + return ! is_null( $this->data->get_shipping_tax_total() ) ? $this->data->get_shipping_tax_total() : 0; }, 'isCompound' => function() { - return ! empty( $this->data->is_compound() ) ? $this->data->is_compound() : null; + return ! is_null( $this->data->is_compound() ) ? $this->data->is_compound() : false; }, 'rate_id' => function() { return ! empty( $this->data->get_rate_id() ) ? $this->data->get_rate_id() : null; diff --git a/includes/model/class-order.php b/includes/model/class-order.php index d30462fc..b6221d58 100644 --- a/includes/model/class-order.php +++ b/includes/model/class-order.php @@ -34,7 +34,7 @@ class Order extends Crud_CPT { 'isPrivate', 'isPublic', 'id', - 'orderId', + 'databaseId', 'orderNumber', 'status', 'date', @@ -79,8 +79,8 @@ class Order extends Crud_CPT { 'id' => function() { return ! empty( $this->data->get_id() ) ? Relay::toGlobalId( 'shop_order', $this->data->get_id() ) : null; }, - 'orderId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID ?? $this->data->get_id(); }, 'date' => function() { return ! empty( $this->data->get_date_created() ) ? $this->data->get_date_created() : null; diff --git a/includes/model/class-product-variation.php b/includes/model/class-product-variation.php index 32294cb6..4de129c9 100644 --- a/includes/model/class-product-variation.php +++ b/includes/model/class-product-variation.php @@ -30,7 +30,7 @@ class Product_Variation extends Crud_CPT { 'isPrivate', 'isPublic', 'id', - 'variationId', + 'databaseId', ); parent::__construct( $allowed_restricted_fields, 'product_variation', $id ); @@ -71,8 +71,8 @@ class Product_Variation extends Crud_CPT { 'id' => function() { return ! empty( $this->data->get_id() ) ? Relay::toGlobalId( 'product_variation', $this->data->get_id() ) : null; }, - 'variationId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID; }, 'name' => function() { return ! empty( $this->data->get_name() ) ? $this->data->get_name() : null; diff --git a/includes/model/class-product.php b/includes/model/class-product.php index 41804812..f4d3fb4c 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -49,7 +49,7 @@ class Product extends Crud_CPT { 'isPrivate', 'isPublic', 'id', - 'productId', + 'databaseId', ); parent::__construct( $allowed_restricted_fields, 'product', $id ); @@ -158,8 +158,8 @@ class Product extends Crud_CPT { 'id' => function() { return ! empty( $this->data->get_id() ) ? Relay::toGlobalId( 'product', $this->data->get_id() ) : null; }, - 'productId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID; }, 'type' => function() { return ! empty( $this->data->get_type() ) ? $this->data->get_type() : null; diff --git a/includes/model/class-refund.php b/includes/model/class-refund.php index db71ed92..eb07c02f 100644 --- a/includes/model/class-refund.php +++ b/includes/model/class-refund.php @@ -35,7 +35,7 @@ class Refund extends Crud_CPT { 'isPrivate', 'isPublic', 'id', - 'refundId', + 'databaseId', ); parent::__construct( $allowed_restricted_fields, 'shop_order_refund', $id ); @@ -53,8 +53,8 @@ class Refund extends Crud_CPT { 'id' => function() { return ! empty( $this->data->get_id() ) ? Relay::toGlobalId( 'shop_order_refund', $this->data->get_id() ) : null; }, - 'refundId' => function() { - return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null; + 'databaseId' => function() { + return $this->ID ?? $this->data->get_id(); }, 'title' => function() { return ! empty( $this->data->get_post_title() ) ? $this->data->get_post_title() : null; diff --git a/includes/model/class-shipping-method.php b/includes/model/class-shipping-method.php index ca276963..6d04ad88 100644 --- a/includes/model/class-shipping-method.php +++ b/includes/model/class-shipping-method.php @@ -30,9 +30,9 @@ class Shipping_Method extends Model { 'isPrivate', 'isPublic', 'id', - 'rateId', + 'databaseId', ); - + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound $restricted_cap = apply_filters( 'shipping_method_restricted_cap', '' ); @@ -60,8 +60,8 @@ class Shipping_Method extends Model { 'id' => function() { return ! empty( $this->data->id ) ? Relay::toGlobalId( 'shipping_method', $this->data->id ) : null; }, - 'methodId' => function() { - return ! empty( $this->data->id ) ? $this->data->id : null; + 'databaseId' => function() { + return $this->ID; }, 'title' => function() { return ! empty( $this->data->method_title ) ? $this->data->method_title : null; diff --git a/includes/model/class-tax-rate.php b/includes/model/class-tax-rate.php index 8f5e4320..d76b56ec 100644 --- a/includes/model/class-tax-rate.php +++ b/includes/model/class-tax-rate.php @@ -30,7 +30,7 @@ class Tax_Rate extends Model { 'isPrivate', 'isPublic', 'id', - 'rateId', + 'databaseId', ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound @@ -54,46 +54,46 @@ class Tax_Rate extends Model { protected function init() { if ( empty( $this->fields ) ) { $this->fields = array( - 'ID' => function() { + 'ID' => function() { return $this->data->tax_rate_id; }, - 'id' => function() { + 'id' => function() { return ! empty( $this->data->tax_rate_id ) ? Relay::toGlobalId( 'tax_rate', $this->data->tax_rate_id ) : null; }, - 'rateId' => function() { - return ! empty( $this->data->tax_rate_id ) ? $this->data->tax_rate_id : null; + 'databaseId' => function() { + return $this->ID; }, - 'country' => function() { + 'country' => function() { return ! empty( $this->data->tax_rate_country ) ? $this->data->tax_rate_country : null; }, - 'state' => function() { + 'state' => function() { return ! empty( $this->data->tax_rate_state ) ? $this->data->tax_rate_state : null; }, - 'city' => function() { + 'city' => function() { return ! empty( $this->data->tax_rate_city ) ? $this->data->tax_rate_city : array( '*' ); }, - 'postcode' => function() { + 'postcode' => function() { return ! empty( $this->data->tax_rate_postcode ) ? $this->data->tax_rate_postcode : array( '*' ); }, - 'rate' => function() { + 'rate' => function() { return ! empty( $this->data->tax_rate ) ? $this->data->tax_rate : null; }, - 'name' => function() { + 'name' => function() { return ! empty( $this->data->tax_rate_name ) ? $this->data->tax_rate_name : null; }, - 'priority' => function() { + 'priority' => function() { return ! empty( $this->data->tax_rate_priority ) ? $this->data->tax_rate_priority : null; }, - 'compound' => function() { + 'compound' => function() { return ! empty( $this->data->tax_rate_compound ) ? $this->data->tax_rate_compound : null; }, - 'shipping' => function() { + 'shipping' => function() { return ! empty( $this->data->tax_rate_shipping ) ? $this->data->tax_rate_shipping : null; }, - 'order' => function() { + 'order' => function() { return ! is_null( $this->data->tax_rate_order ) ? absint( $this->data->tax_rate_order ) : null; }, - 'class' => function() { + 'class' => function() { return ! is_null( $this->data->tax_rate_class ) ? $this->data->tax_rate_class : ''; }, ); diff --git a/includes/type/interface/class-product.php b/includes/type/interface/class-product.php index 5dac38c5..a3c32ea3 100644 --- a/includes/type/interface/class-product.php +++ b/includes/type/interface/class-product.php @@ -114,9 +114,9 @@ class Product { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the product', 'wp-graphql-woocommerce' ), ), - 'productId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order. Equivalent to WP_Post->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the product in the database', 'wp-graphql-woocommerce' ), ), 'slug' => array( 'type' => 'String', diff --git a/includes/type/object/class-coupon-type.php b/includes/type/object/class-coupon-type.php index 1508afb0..38a0e981 100644 --- a/includes/type/object/class-coupon-type.php +++ b/includes/type/object/class-coupon-type.php @@ -34,9 +34,9 @@ class Coupon_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the coupon', 'wp-graphql-woocommerce' ), ), - 'couponId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order. Equivalent to WP_Post->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the coupon in the database', 'wp-graphql-woocommerce' ), ), 'code' => array( 'type' => 'String', diff --git a/includes/type/object/class-customer-type.php b/includes/type/object/class-customer-type.php index 6adc1629..0f5bd04e 100644 --- a/includes/type/object/class-customer-type.php +++ b/includes/type/object/class-customer-type.php @@ -33,9 +33,9 @@ class Customer_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the customer', 'wp-graphql-woocommerce' ), ), - 'customerId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the user. Equivalent to WP_User->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the customer in the database', 'wp-graphql-woocommerce' ), ), 'isVatExempt' => array( 'type' => 'Boolean', diff --git a/includes/type/object/class-order-item-type.php b/includes/type/object/class-order-item-type.php index 28e41cb7..758911d0 100644 --- a/includes/type/object/class-order-item-type.php +++ b/includes/type/object/class-order-item-type.php @@ -295,9 +295,9 @@ class Order_Item_Type { private static function get_fields( $fields = array() ) { return array_merge( array( - 'itemId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order item.', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the order item in the database', 'wp-graphql-woocommerce' ), ), 'orderId' => array( 'type' => 'Int', diff --git a/includes/type/object/class-order-type.php b/includes/type/object/class-order-type.php index 04b81109..43319709 100644 --- a/includes/type/object/class-order-type.php +++ b/includes/type/object/class-order-type.php @@ -37,9 +37,9 @@ class Order_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the order', 'wp-graphql-woocommerce' ), ), - 'orderId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order. Equivalent to WP_Post->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the order in the database', 'wp-graphql-woocommerce' ), ), 'orderKey' => array( 'type' => 'String', diff --git a/includes/type/object/class-product-variation-type.php b/includes/type/object/class-product-variation-type.php index 95d955b6..d63cb7c0 100644 --- a/includes/type/object/class-product-variation-type.php +++ b/includes/type/object/class-product-variation-type.php @@ -35,9 +35,9 @@ class Product_Variation_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the product variation', 'wp-graphql-woocommerce' ), ), - 'variationId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order. Equivalent to WP_Post->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the refund in the database', 'wp-graphql-woocommerce' ), ), 'name' => array( 'type' => 'String', diff --git a/includes/type/object/class-refund-type.php b/includes/type/object/class-refund-type.php index 5ff62e7f..d636a0d3 100644 --- a/includes/type/object/class-refund-type.php +++ b/includes/type/object/class-refund-type.php @@ -35,9 +35,9 @@ class Refund_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the refund', 'wp-graphql-woocommerce' ), ), - 'refundId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The Id of the order. Equivalent to WP_Post->ID', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the refund in the database', 'wp-graphql-woocommerce' ), ), 'title' => array( 'type' => 'String', diff --git a/includes/type/object/class-shipping-method-type.php b/includes/type/object/class-shipping-method-type.php index 49d39268..58d10ee9 100644 --- a/includes/type/object/class-shipping-method-type.php +++ b/includes/type/object/class-shipping-method-type.php @@ -33,9 +33,9 @@ class Shipping_Method_Type { 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the tax rate.', 'wp-graphql-woocommerce' ), ), - 'methodId' => array( + 'databaseId' => array( 'type' => array( 'non_null' => 'ID' ), - 'description' => __( 'The ID of the shipping method.', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the shipping method in the database', 'wp-graphql-woocommerce' ), ), 'title' => array( 'type' => 'String', diff --git a/includes/type/object/class-tax-rate-type.php b/includes/type/object/class-tax-rate-type.php index 0caa0dc4..58a14c61 100644 --- a/includes/type/object/class-tax-rate-type.php +++ b/includes/type/object/class-tax-rate-type.php @@ -30,55 +30,55 @@ class Tax_Rate_Type { 'description' => __( 'A Tax rate object', 'wp-graphql-woocommerce' ), 'interfaces' => array( 'Node' ), 'fields' => array( - 'id' => array( + 'id' => array( 'type' => array( 'non_null' => 'ID' ), 'description' => __( 'The globally unique identifier for the tax rate.', 'wp-graphql-woocommerce' ), ), - 'rateId' => array( + 'databaseId' => array( 'type' => 'Int', - 'description' => __( 'The ID of the tax rate.', 'wp-graphql-woocommerce' ), + 'description' => __( 'The ID of the customer in the database', 'wp-graphql-woocommerce' ), ), - 'country' => array( + 'country' => array( 'type' => 'String', 'description' => __( 'Country ISO 3166 code.', 'wp-graphql-woocommerce' ), ), - 'state' => array( + 'state' => array( 'type' => 'String', 'description' => __( 'State code.', 'wp-graphql-woocommerce' ), ), - 'postcode' => array( + 'postcode' => array( 'type' => array( 'list_of' => 'String' ), 'description' => __( 'Postcode/ZIP.', 'wp-graphql-woocommerce' ), ), - 'city' => array( + 'city' => array( 'type' => array( 'list_of' => 'String' ), 'description' => __( 'City name.', 'wp-graphql-woocommerce' ), ), - 'rate' => array( + 'rate' => array( 'type' => 'String', 'description' => __( 'Tax rate.', 'wp-graphql-woocommerce' ), ), - 'name' => array( + 'name' => array( 'type' => 'String', 'description' => __( 'Tax rate name.', 'wp-graphql-woocommerce' ), ), - 'priority' => array( + 'priority' => array( 'type' => 'Int', 'description' => __( 'Tax priority.', 'wp-graphql-woocommerce' ), ), - 'compound' => array( + 'compound' => array( 'type' => 'Boolean', 'description' => __( 'Whether or not this is a compound rate.', 'wp-graphql-woocommerce' ), ), - 'shipping' => array( + 'shipping' => array( 'type' => 'Boolean', 'description' => __( 'Whether or not this tax rate also gets applied to shipping.', 'wp-graphql-woocommerce' ), ), - 'order' => array( + 'order' => array( 'type' => 'Int', 'description' => __( 'Indicates the order that will appear in queries.', 'wp-graphql-woocommerce' ), ), - 'class' => array( + 'class' => array( 'type' => 'TaxClassEnum', 'description' => __( 'Tax class. Default is standard.', 'wp-graphql-woocommerce' ), ), diff --git a/tests/_support/Helper/crud-helpers/cart.php b/tests/_support/Helper/crud-helpers/cart.php index 425e2914..bc77d0ec 100644 --- a/tests/_support/Helper/crud-helpers/cart.php +++ b/tests/_support/Helper/crud-helpers/cart.php @@ -60,12 +60,12 @@ class CartHelper extends WCG_Helper { return array( 'key' => $item['key'], 'product' => array( - 'id' => Relay::toGlobalId( 'product', $item['product_id'] ), - 'productId' => $item['product_id'], + 'id' => Relay::toGlobalId( 'product', $item['product_id'] ), + 'databaseId' => $item['product_id'], ), 'variation' => array( - 'id' => Relay::toGlobalId( 'product_variation', $item['variation_id'] ), - 'variationId' => $item['variation_id'] + 'id' => Relay::toGlobalId( 'product_variation', $item['variation_id'] ), + 'databaseId' => $item['variation_id'] ), 'quantity' => $item['quantity'], 'subtotal' => \wc_graphql_price( $item['line_subtotal'] ), diff --git a/tests/_support/Helper/crud-helpers/coupon.php b/tests/_support/Helper/crud-helpers/coupon.php index 55329ebc..b9e57cd4 100644 --- a/tests/_support/Helper/crud-helpers/coupon.php +++ b/tests/_support/Helper/crud-helpers/coupon.php @@ -51,7 +51,7 @@ class CouponHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'couponId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'code' => $data->get_code(), 'amount' => $data->get_amount(), 'date' => $data->get_date_created()->__toString(), @@ -82,7 +82,7 @@ class CouponHelper extends WCG_Helper { 'products' => [ 'nodes' => array_map( function( $id ) { - return array( 'productId' => $id ); + return array( 'databaseId' => $id ); }, $data->get_product_ids() ), @@ -90,7 +90,7 @@ class CouponHelper extends WCG_Helper { 'excludedProducts' => [ 'nodes' => array_map( function( $id ) { - return array( 'productId' => $id ); + return array( 'databaseId' => $id ); }, $data->get_excluded_product_ids() ), @@ -114,7 +114,7 @@ class CouponHelper extends WCG_Helper { 'usedBy' => [ 'nodes' => array_map( function( $id ) { - return array( 'customerId' => $id ); + return array( 'databaseId' => $id ); }, $data->get_used_by() ), @@ -127,4 +127,4 @@ class CouponHelper extends WCG_Helper { return array(); } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/customer.php b/tests/_support/Helper/crud-helpers/customer.php index 2a481faa..29577545 100644 --- a/tests/_support/Helper/crud-helpers/customer.php +++ b/tests/_support/Helper/crud-helpers/customer.php @@ -82,7 +82,7 @@ class CustomerHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'customerId' => $id, + 'databaseId' => $id, 'isVatExempt' => $data->get_is_vat_exempt(), 'hasCalculatedShipping' => $data->has_calculated_shipping(), 'calculatedShipping' => $data->get_calculated_shipping(), @@ -99,7 +99,7 @@ class CustomerHelper extends WCG_Helper { ? $data->get_date_modified()->__toString() : null, 'lastOrder' => ! empty( $data->get_last_order() ) - ? array( + ? array( 'id' => Relay::toGlobalId( 'shop_order', $data->get_last_order()->get_id() ), 'customerId' => $data->get_last_order(), ) @@ -183,23 +183,23 @@ class CustomerHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'customerId' => $id, - 'isVatExempt' => null, - 'hasCalculatedShipping' => null, - 'calculatedShipping' => null, - 'orderCount' => null, - 'totalSpent' => null, - 'username' => null, - 'email' => null, - 'firstName' => null, - 'lastName' => null, - 'displayName' => $data->get_display_name(), - 'role' => null, - 'date' => null, - 'modified' => null, - 'lastOrder' => null, - 'billing' => null, - 'shipping' => null, + 'databaseId' => $id, + 'isVatExempt' => null, + 'hasCalculatedShipping' => null, + 'calculatedShipping' => null, + 'orderCount' => null, + 'totalSpent' => null, + 'username' => null, + 'email' => null, + 'firstName' => null, + 'lastName' => null, + 'displayName' => $data->get_display_name(), + 'role' => null, + 'date' => null, + 'modified' => null, + 'lastOrder' => null, + 'billing' => null, + 'shipping' => null, 'isPayingCustomer' => null, 'jwtAuthToken' => null, 'jwtRefreshToken' => null, @@ -212,7 +212,7 @@ class CustomerHelper extends WCG_Helper { if ( empty( $items ) ) { return array(); } - + $nodes = array(); foreach ( $items as $item ) { $nodes[] = array( @@ -223,11 +223,11 @@ class CustomerHelper extends WCG_Helper { ? $item['downloads_remaining'] : null, 'name' => $item['download_name'], - 'product' => array( 'productId' => $item['product_id'] ), + 'product' => array( 'databaseId' => $item['product_id'] ), 'download' => array( 'downloadId' => $item['download_id'] ), ); } return $nodes; } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/order.php b/tests/_support/Helper/crud-helpers/order.php index a731b7f7..477d9b54 100644 --- a/tests/_support/Helper/crud-helpers/order.php +++ b/tests/_support/Helper/crud-helpers/order.php @@ -38,7 +38,7 @@ class OrderHelper extends WCG_Helper { if ( $save ) { return $order->save(); } - + return $order; } @@ -60,11 +60,11 @@ class OrderHelper extends WCG_Helper { $order->set_shipping_state( $customer->get_shipping_state() ); $order->set_shipping_postcode( $customer->get_shipping_postcode() ); $order->set_shipping_country( $customer->get_shipping_country() ); - + if ( $save ) { return $order->save(); } - + return $order; } @@ -90,7 +90,7 @@ class OrderHelper extends WCG_Helper { ); $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception $order = wc_create_order( $order_data ); - + // Add line items if ( ! empty( $items['line_items'] ) ) { foreach( $items['line_items'] as $item ) { @@ -109,12 +109,12 @@ class OrderHelper extends WCG_Helper { } } $order->save(); - - + + // Add billing / shipping address $order = $this->set_to_customer_billing_address( $order, $customer_id, false ); $order = $this->set_to_customer_shipping_address( $order, $customer_id, false ); - + // Add shipping costs $shipping_taxes = WC_Tax::calc_shipping_tax( '10', WC_Tax::get_shipping_tax_rates() ); $rate = new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate' ); @@ -129,11 +129,11 @@ class OrderHelper extends WCG_Helper { $item->add_meta_data( $key, $value, true ); } $order->add_item( $item ); - + // Set payment gateway $payment_gateways = WC()->payment_gateways->payment_gateways(); $order->set_payment_method( $payment_gateways['bacs'] ); - + // Set totals $order->set_shipping_total( 10 ); $order->set_discount_total( 0 ); @@ -141,7 +141,7 @@ class OrderHelper extends WCG_Helper { $order->set_cart_tax( 0 ); $order->set_shipping_tax( 0 ); $order->set_total( 50 ); // 4 x $10 simple helper product - + // Set meta data. if ( ! empty( $args['meta_data'] ) ) { $order->set_meta_data( $args['meta_data'] ); @@ -157,7 +157,7 @@ class OrderHelper extends WCG_Helper { public function has_product( $id, $product_id ) { $order = new WC_Order( $id ); - $line_items = $order->get_items(); + $line_items = $order->get_items(); foreach ( $line_items as $item ) { if ( $item['product_id'] == $product_id ) { return true; @@ -182,7 +182,7 @@ class OrderHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'orderId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'currency' => ! empty( $data->get_currency() ) ? $data->get_currency() : null, 'orderVersion' => ! empty( $data->get_version() ) ? $data->get_version() : null, 'date' => $data->get_date_created()->__toString(), @@ -314,7 +314,7 @@ class OrderHelper extends WCG_Helper { 'needsProcessing' => $data->needs_processing(), ); } - + public function print_restricted_query( $id ) { $data = new WC_Order( $id ); @@ -324,7 +324,7 @@ class OrderHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'orderId' => $id, + 'databaseId' => $id, 'currency' => null, 'orderVersion' => null, 'date' => $data->get_date_created()->__toString(), @@ -448,7 +448,7 @@ class OrderHelper extends WCG_Helper { if ( ! $data->get_id() ) { return null; } - + $nodes = array(); foreach ( $data->get_downloadable_items() as $item ) { $nodes[] = array( @@ -459,11 +459,11 @@ class OrderHelper extends WCG_Helper { ? $item['downloads_remaining'] : null, 'name' => $item['download_name'], - 'product' => array( 'productId' => $item['product_id'] ), + 'product' => array( 'databaseId' => $item['product_id'] ), 'download' => array( 'downloadId' => $item['download_id'] ), ); } return $nodes; } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/product-variation.php b/tests/_support/Helper/crud-helpers/product-variation.php index e660bbcf..c8462386 100644 --- a/tests/_support/Helper/crud-helpers/product-variation.php +++ b/tests/_support/Helper/crud-helpers/product-variation.php @@ -105,7 +105,7 @@ class ProductVariationHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'variationId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'name' => $data->get_name(), 'date' => $data->get_date_created()->__toString(), 'modified' => ! empty( $data->get_date_created() ) @@ -200,7 +200,7 @@ class ProductVariationHelper extends WCG_Helper { if ( empty( $downloads ) ) { return null; } - + $results = array(); foreach ( $downloads as $download ) { $results[] = array( @@ -214,7 +214,7 @@ class ProductVariationHelper extends WCG_Helper { 'file' => $download->get_file(), ); } - + return $results; } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/product.php b/tests/_support/Helper/crud-helpers/product.php index 61e8a84e..d8b09bd0 100644 --- a/tests/_support/Helper/crud-helpers/product.php +++ b/tests/_support/Helper/crud-helpers/product.php @@ -170,14 +170,14 @@ class ProductHelper extends WCG_Helper { $attribute_1->set_visible( true ); $attribute_1->set_variation( true ); - $attribute_data = $this->create_attribute( 'color', array( 'red', 'blue', 'green' ) ); + $attribute_data = $this->create_attribute( 'color', array( 'red' ) ); $attribute_2 = new WC_Product_Attribute(); $attribute_2->set_id( $attribute_data['attribute_id'] ); $attribute_2->set_name( $attribute_data['attribute_taxonomy'] ); $attribute_2->set_options( $attribute_data['term_ids'] ); $attribute_2->set_position( 2 ); $attribute_2->set_visible( true ); - $attribute_2->set_variation( true ); + $attribute_2->set_variation( false ); $product->set_attributes( array( $attribute_1, $attribute_2 ) ); $product->set_default_attributes( array( 'size' => 'small' ) ); @@ -313,7 +313,7 @@ class ProductHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'productId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'name' => $data->get_name(), 'slug' => $data->get_slug(), 'date' => $data->get_date_created()->__toString(), diff --git a/tests/_support/Helper/crud-helpers/refund.php b/tests/_support/Helper/crud-helpers/refund.php index 60226fe1..11c59ec3 100644 --- a/tests/_support/Helper/crud-helpers/refund.php +++ b/tests/_support/Helper/crud-helpers/refund.php @@ -48,7 +48,7 @@ class RefundHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'refundId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'title' => $data->get_post_title(), 'reason' => $data->get_reason(), 'amount' => $data->get_amount(), @@ -66,11 +66,11 @@ class RefundHelper extends WCG_Helper { return array( 'id' => $this->to_relay_id( $id ), - 'refundId' => $data->get_id(), + 'databaseId' => $data->get_id(), 'title' => null, 'reason' => null, 'amount' => null, 'refundedBy' => null, ); } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/shipping-method.php b/tests/_support/Helper/crud-helpers/shipping-method.php index 933dd489..b0aea8a2 100644 --- a/tests/_support/Helper/crud-helpers/shipping-method.php +++ b/tests/_support/Helper/crud-helpers/shipping-method.php @@ -59,7 +59,7 @@ class ShippingMethodHelper extends WCG_Helper { $method = $methods[ $id ]; return array( 'id' => $this->to_relay_id( $id ), - 'methodId' => $id, + 'databaseId' => $id, 'title' => $method->method_title, 'description' => $method->method_description, ); @@ -68,4 +68,4 @@ class ShippingMethodHelper extends WCG_Helper { public function print_nodes( $ids = 0, $processors = array() ) { return array(); } -} \ No newline at end of file +} diff --git a/tests/_support/Helper/crud-helpers/tax-rate.php b/tests/_support/Helper/crud-helpers/tax-rate.php index bc679696..ae8b38c7 100644 --- a/tests/_support/Helper/crud-helpers/tax-rate.php +++ b/tests/_support/Helper/crud-helpers/tax-rate.php @@ -92,19 +92,19 @@ class TaxRateHelper extends WCG_Helper { return $rate ? array( - 'id' => $this->to_relay_id( $rate->tax_rate_id ), - 'rateId' => absint( $rate->tax_rate_id ), - 'country' => ! empty( $rate->tax_rate_country ) ? $rate->tax_rate_country : null, - 'state' => ! empty( $rate->tax_rate_state ) ? $rate->tax_rate_state : null, - 'postcode' => ! empty( $rate->tax_rate_postcode ) ? $rate->tax_rate_postcode : array( "*" ), - 'city' => ! empty( $rate->tax_rate_city ) ? $rate->tax_rate_city : array( "*" ), - 'rate' => ! empty( $rate->tax_rate ) ? $rate->tax_rate : null, - 'name' => ! empty( $rate->tax_rate_name ) ? $rate->tax_rate_name : null, - 'priority' => absint( $rate->tax_rate_priority ), - 'compound' => (bool) $rate->tax_rate_compound, - 'shipping' => (bool) $rate->tax_rate_shipping, - 'order' => absint( $rate->tax_rate_order ), - 'class' => ! empty( $rate->tax_rate_class ) + 'id' => $this->to_relay_id( $rate->tax_rate_id ), + 'databaseId' => absint( $rate->tax_rate_id ), + 'country' => ! empty( $rate->tax_rate_country ) ? $rate->tax_rate_country : null, + 'state' => ! empty( $rate->tax_rate_state ) ? $rate->tax_rate_state : null, + 'postcode' => ! empty( $rate->tax_rate_postcode ) ? $rate->tax_rate_postcode : array( "*" ), + 'city' => ! empty( $rate->tax_rate_city ) ? $rate->tax_rate_city : array( "*" ), + 'rate' => ! empty( $rate->tax_rate ) ? $rate->tax_rate : null, + 'name' => ! empty( $rate->tax_rate_name ) ? $rate->tax_rate_name : null, + 'priority' => absint( $rate->tax_rate_priority ), + 'compound' => (bool) $rate->tax_rate_compound, + 'shipping' => (bool) $rate->tax_rate_shipping, + 'order' => absint( $rate->tax_rate_order ), + 'class' => ! empty( $rate->tax_rate_class ) ? WPEnumType::get_safe_name( $rate->tax_rate_class ) : 'STANDARD', ) @@ -114,4 +114,4 @@ class TaxRateHelper extends WCG_Helper { public function print_nodes( $ids = 0, $processors = array() ) { return array(); } -} \ No newline at end of file +} diff --git a/tests/wpunit/CartQueriesTest.php b/tests/wpunit/CartQueriesTest.php index 181fdaef..1eefd6fd 100644 --- a/tests/wpunit/CartQueriesTest.php +++ b/tests/wpunit/CartQueriesTest.php @@ -87,12 +87,12 @@ class CartQueriesTest extends \Codeception\TestCase\WPTestCase { product { ... on VariableProduct { id - productId + databaseId } } variation { id - variationId + databaseId } quantity subtotal diff --git a/tests/wpunit/CheckoutMutationTest.php b/tests/wpunit/CheckoutMutationTest.php index e532aa31..fe5931ce 100644 --- a/tests/wpunit/CheckoutMutationTest.php +++ b/tests/wpunit/CheckoutMutationTest.php @@ -114,7 +114,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { clientMutationId order { id - orderId + databaseId currency orderVersion date @@ -185,7 +185,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { downloadsRemaining name product { - productId + databaseId } download { downloadId @@ -200,7 +200,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { } couponLines { nodes { - itemId + databaseId orderId code discount @@ -212,7 +212,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { } feeLines { nodes { - itemId + databaseId orderId amount name @@ -224,7 +224,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { } shippingLines { nodes { - itemId + databaseId orderId methodTitle total @@ -240,7 +240,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { shippingTaxTotal isCompound taxRate { - rateId + databaseId } } } @@ -358,7 +358,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('checkout', $actual['data'] ); $this->assertArrayHasKey('order', $actual['data']['checkout'] ); $this->assertArrayHasKey('id', $actual['data']['checkout']['order'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['databaseId'] ); // Get Available payment gateways. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -385,7 +385,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -402,14 +402,14 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), - 'orderId' => $item->get_order_id(), - 'amount' => $item->get_amount(), - 'name' => $item->get_name(), - 'taxStatus' => strtoupper( $item->get_tax_status() ), - 'total' => $item->get_total(), - 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'databaseId' => $item->get_id(), + 'orderId' => $item->get_order_id(), + 'amount' => $item->get_amount(), + 'name' => $item->get_name(), + 'taxStatus' => strtoupper( $item->get_tax_status() ), + 'total' => $item->get_total(), + 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -424,14 +424,14 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { function( $item ) { return array( - 'itemId' => $item->get_id(), - 'orderId' => $item->get_order_id(), - 'methodTitle' => $item->get_method_title(), - 'total' => $item->get_total(), - 'totalTax' => !empty( $item->get_total_tax() ) + 'databaseId' => $item->get_id(), + 'orderId' => $item->get_order_id(), + 'methodTitle' => $item->get_method_title(), + 'total' => $item->get_total(), + 'totalTax' => !empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'taxClass' => ! empty( $item->get_tax_class() ) ? $item->get_tax_class() === 'inherit' ? WPEnumType::get_safe_name( 'inherit cart' ) : WPEnumType::get_safe_name( $item->get_tax_class() ) @@ -452,7 +452,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -554,7 +554,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('checkout', $actual['data'] ); $this->assertArrayHasKey('order', $actual['data']['checkout'] ); $this->assertArrayHasKey('id', $actual['data']['checkout']['order'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['databaseId'] ); // Get Available payment gateways. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -577,7 +577,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -594,14 +594,14 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), - 'orderId' => $item->get_order_id(), - 'amount' => $item->get_amount(), - 'name' => $item->get_name(), - 'taxStatus' => strtoupper( $item->get_tax_status() ), - 'total' => $item->get_total(), - 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'databaseId' => $item->get_id(), + 'orderId' => $item->get_order_id(), + 'amount' => $item->get_amount(), + 'name' => $item->get_name(), + 'taxStatus' => strtoupper( $item->get_tax_status() ), + 'total' => $item->get_total(), + 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -616,7 +616,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'methodTitle' => $item->get_method_title(), 'total' => $item->get_total(), @@ -644,7 +644,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -751,7 +751,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('checkout', $actual['data'] ); $this->assertArrayHasKey('order', $actual['data']['checkout'] ); $this->assertArrayHasKey('id', $actual['data']['checkout']['order'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['databaseId'] ); // Get Available payment gateways. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -774,7 +774,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -791,14 +791,14 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), - 'orderId' => $item->get_order_id(), - 'amount' => $item->get_amount(), - 'name' => $item->get_name(), - 'taxStatus' => strtoupper( $item->get_tax_status() ), - 'total' => $item->get_total(), - 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'databaseId' => $item->get_id(), + 'orderId' => $item->get_order_id(), + 'amount' => $item->get_amount(), + 'name' => $item->get_name(), + 'taxStatus' => strtoupper( $item->get_tax_status() ), + 'total' => $item->get_total(), + 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -813,7 +813,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'methodTitle' => $item->get_method_title(), 'total' => $item->get_total(), @@ -841,7 +841,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -956,7 +956,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('order', $actual['data']['checkout'] ); $this->assertArrayHasKey('id', $actual['data']['checkout']['order'] ); $this->assertEquals('COMPLETED', $actual['data']['checkout']['order']['status'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['databaseId'] ); // Get Available payment gateways. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -979,7 +979,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -996,14 +996,14 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), - 'orderId' => $item->get_order_id(), - 'amount' => $item->get_amount(), - 'name' => $item->get_name(), - 'taxStatus' => strtoupper( $item->get_tax_status() ), - 'total' => $item->get_total(), - 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'databaseId' => $item->get_id(), + 'orderId' => $item->get_order_id(), + 'amount' => $item->get_amount(), + 'name' => $item->get_name(), + 'taxStatus' => strtoupper( $item->get_tax_status() ), + 'total' => $item->get_total(), + 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -1023,7 +1023,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -1193,7 +1193,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { checkout( input: $input ) { clientMutationId order { - orderId + databaseId metaData { key } lineItems { nodes { @@ -1238,8 +1238,8 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('data', $actual ); $this->assertArrayHasKey('checkout', $actual['data'] ); $this->assertArrayHasKey('order', $actual['data']['checkout'] ); - $this->assertArrayHasKey('orderId', $actual['data']['checkout']['order'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['orderId'] ); + $this->assertArrayHasKey('databaseId', $actual['data']['checkout']['order'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['checkout']['order']['databaseId'] ); // Get Available payment gateways. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -1249,7 +1249,7 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { 'checkout' => array( 'clientMutationId' => 'someId', 'order' => array( - 'orderId' => $order->get_id(), + 'databaseId' => $order->get_id(), 'metaData' => array( array( 'key' => 'is_vat_exempt', ), array( 'key' => '_stripe_source_id' ), diff --git a/tests/wpunit/ConnectionPaginationTest.php b/tests/wpunit/ConnectionPaginationTest.php index 29e189a3..e86e0dd5 100644 --- a/tests/wpunit/ConnectionPaginationTest.php +++ b/tests/wpunit/ConnectionPaginationTest.php @@ -45,7 +45,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $this->coupons->create(), $this->coupons->create(), ); - + usort( $coupons, function( $key_a, $key_b ) { @@ -68,12 +68,12 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { } } '; - + $this->set_user( $this->shop_manager ); /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -100,10 +100,10 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $expected = $this->coupons->print_nodes( array_slice( $coupons, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -139,7 +139,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $this->products->create_simple(), $this->products->create_simple(), ); - + usort( $products, function( $key_a, $key_b ) { @@ -165,7 +165,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -192,10 +192,10 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $expected = $this->products->print_nodes( array_slice( $products, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -231,7 +231,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $this->orders->create(), $this->orders->create(), ); - + usort( $orders, function( $key_a, $key_b ) { @@ -254,12 +254,12 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { } } '; - + wp_set_current_user( $this->shop_manager ); /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -286,10 +286,10 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $expected = $this->orders->print_nodes( array_slice( $orders, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -326,7 +326,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $this->refunds->create( $order, array( 'amount' => 0.5 ) ), $this->refunds->create( $order, array( 'amount' => 0.5 ) ), ); - + usort( $refunds, function( $key_a, $key_b ) { @@ -349,12 +349,12 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { } } '; - + wp_set_current_user( $this->shop_manager ); /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -381,10 +381,10 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $expected = $this->refunds->print_nodes( array_slice( $refunds, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -420,7 +420,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $this->customers->create(), $this->customers->create(), ); - + usort( $customers, function( $key_a, $key_b ) { @@ -443,12 +443,12 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { } } '; - + wp_set_current_user( $this->shop_manager ); /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -475,10 +475,10 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $expected = $this->customers->print_nodes( array_slice( $customers, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -570,7 +570,7 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { downloadableItems(first: $first, last: $last, after: $after, before: $before) { nodes { product { - productId + databaseId } } pageInfo { @@ -581,17 +581,17 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { } } } - + } } } '; - + $this->set_user( $customer_id ); /** * Assertion One - * + * * Test "first" parameter. */ $variables = array( 'first' => 2 ); @@ -621,16 +621,16 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $actual = $results['data']['customer']['orders']['nodes'][0]['downloadableItems']['nodes']; $expected = array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array_slice( $downloable_products, 0, 2 ) ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * Test "after" parameter. */ $variables = array( 'first' => 3, 'after' => $end_cursor ); @@ -659,11 +659,11 @@ class ConnectionPaginationTest extends \Codeception\TestCase\WPTestCase { $actual = $results['data']['customer']['orders']['nodes'][0]['downloadableItems']['nodes']; $expected = array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array_slice( $downloable_products, 2, 3 ) ); $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +} diff --git a/tests/wpunit/CouponQueriesTest.php b/tests/wpunit/CouponQueriesTest.php index f69ab6a7..c4a98884 100644 --- a/tests/wpunit/CouponQueriesTest.php +++ b/tests/wpunit/CouponQueriesTest.php @@ -34,7 +34,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { query ($id: ID!){ coupon(id: $id) { id - couponId + databaseId code amount date @@ -55,14 +55,14 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { products { nodes { ... on SimpleProduct { - productId + databaseId } } } excludedProducts { nodes { ... on SimpleProduct { - productId + databaseId } } } @@ -78,7 +78,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { } usedBy { nodes { - customerId + databaseId } } } @@ -113,7 +113,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Testing "ID" ID type. */ $variables = array( @@ -135,7 +135,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Testing "DATABASE_ID" ID type */ $variables = array( @@ -157,7 +157,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * Testing "CODE" ID type. */ $variables = array( @@ -209,7 +209,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Should return null due to lack of required capabilities */ wp_set_current_user( $this->customer ); @@ -224,7 +224,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Should return data because user has required capabilities */ wp_set_current_user( $this->shop_manager ); @@ -238,7 +238,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * Tests 'code' where argument */ wp_set_current_user( $this->shop_manager ); @@ -267,7 +267,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Four - * + * * Tests 'include' where argument */ wp_set_current_user( $this->shop_manager ); @@ -295,7 +295,7 @@ class CouponQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Five - * + * * Tests 'exclude' where argument */ wp_set_current_user( $this->shop_manager ); diff --git a/tests/wpunit/CustomerMutationsTest.php b/tests/wpunit/CustomerMutationsTest.php index 8ac4b3f3..a668ce57 100644 --- a/tests/wpunit/CustomerMutationsTest.php +++ b/tests/wpunit/CustomerMutationsTest.php @@ -7,7 +7,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { update_option( 'users_can_register', 1 ); $this->helper = $this->getModule('\Helper\Wpunit')->customer(); - + // Register Info $this->first_name = 'Peter'; $this->last_name = 'Parker'; @@ -98,7 +98,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { authToken refreshToken customer { - customerId + databaseId username email firstName @@ -155,7 +155,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { authToken refreshToken customer { - customerId + databaseId username email firstName @@ -205,7 +205,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testRegisterMutationWithoutCustomerInfo() { /** * Assertion One - * + * * Tests mutation without a providing WooCommerce specific customer information. */ $actual = $this->registerCustomer( @@ -232,7 +232,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->email, 'username' => $this->username, 'firstName' => $this->first_name, @@ -253,7 +253,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testRegisterMutationWithBillingInfo() { /** * Assertion One - * + * * Tests mutation with customer billing information. */ $actual = $this->registerCustomer( @@ -281,7 +281,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->email, 'username' => $this->username, 'firstName' => $this->first_name, @@ -302,7 +302,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testRegisterMutationWithShippingSameAsBillingInfo() { /** * Assertion One - * + * * Tests mutation using "shippingSameAsBilling" field. */ $actual = $this->registerCustomer( @@ -331,7 +331,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->email, 'username' => $this->username, 'firstName' => $this->first_name, @@ -355,7 +355,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testRegisterMutationWithBillingAndShippingInfo() { /** * Assertion One - * + * * Tests mutation with customer shipping information. */ $actual = $this->registerCustomer( @@ -384,7 +384,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->email, 'username' => $this->username, 'firstName' => $this->first_name, @@ -405,7 +405,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testUpdateMutation() { /** * Assertion One - * + * * Tests mutation without a providing WooCommerce specific customer information. */ $this->registerCustomer( @@ -446,7 +446,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->new_email, 'username' => $this->username, 'firstName' => $this->new_first_name, @@ -464,7 +464,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { public function testUpdateMutationWithShippingSameAsBilling() { /** * Assertion One - * + * * Tests mutation without a providing WooCommerce specific customer information. */ $this->registerCustomer( @@ -501,7 +501,7 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { 'authToken' => \WPGraphQL\JWT_Authentication\Auth::get_token( $user ), 'refreshToken' => \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $user ), 'customer' => array( - 'customerId' => $user->ID, + 'databaseId' => $user->ID, 'email' => $this->email, 'username' => $this->username, 'firstName' => $this->first_name, @@ -518,4 +518,4 @@ class CustomerMutationsTest extends \Codeception\TestCase\WPTestCase { $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +} diff --git a/tests/wpunit/CustomerQueriesTest.php b/tests/wpunit/CustomerQueriesTest.php index 022ac457..d27e2b51 100644 --- a/tests/wpunit/CustomerQueriesTest.php +++ b/tests/wpunit/CustomerQueriesTest.php @@ -35,7 +35,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { query ( $id: ID, $customerId: Int ) { customer( id: $id, customerId: $customerId ) { id - customerId + databaseId isVatExempt hasCalculatedShipping calculatedShipping @@ -51,7 +51,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { modified lastOrder { id - orderId + databaseId } billing { firstName @@ -86,7 +86,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Query should return null value due to lack of permissions. */ $this->set_user( $this->customer ); @@ -105,7 +105,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Query should return requested data because user queried themselves. */ $variables = array( 'id' => Relay::toGlobalId( 'customer', $this->customer ) ); @@ -122,7 +122,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * Query should return requested data because has sufficient permissions, * but should not have access to JWT fields. */ @@ -142,7 +142,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Four - * + * * Query should return data corresponding with current user when no ID is provided. */ $this->set_user( $this->new_customer ); @@ -156,10 +156,10 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { // Clear customer cache. $this->getModule('\Helper\Wpunit')->clear_loader_cache( 'wc_customer' ); - + /** * Assertion Five - * + * * Query should return requested data because user queried themselves. */ $this->set_user( $this->new_customer ); @@ -177,7 +177,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Six - * + * * Query should return null value due to lack of permissions.. */ $this->set_user( $this->customer ); @@ -235,7 +235,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Query should return null value due to lack of capabilities... */ $this->set_user( $this->customer ); @@ -252,7 +252,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Query should return requested data because user has proper capabilities. */ $this->set_user( $this->shop_manager ); @@ -272,7 +272,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * Tests "search" where argument. */ $variables = array( 'search' => 'megaman8080' ); @@ -300,7 +300,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Four - * + * * Tests "include" where argument. */ $variables = array( 'include' => array( $user_id ) ); @@ -327,7 +327,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Five - * + * * Tests "exclude" where argument. */ $variables = array( 'exclude' => array( $user_id ) ); @@ -354,7 +354,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Six - * + * * Tests "email" where argument. */ $variables = array( 'email' => 'gotcha@example.com' ); @@ -382,8 +382,8 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Seven - * - * Tests "role" where argument. + * + * Tests "role" where argument. */ $variables = array( 'role' => 'SHOP_MANAGER' ); $actual = graphql( array( 'query' => $query, 'variables' => $variables ) ); @@ -402,7 +402,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Eight - * + * * Tests "roleIn" where argument. Should */ $variables = array( 'roleIn' => array( 'SHOP_MANAGER' ) ); @@ -422,7 +422,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Nine - * + * * Tests "roleNotIn" where argument. */ $variables = array( 'roleNotIn' => array( 'SHOP_MANAGER' ) ); @@ -434,7 +434,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { get_users( array( 'role__not_in' => 'shop_manager', - 'fields' => 'ID', + 'fields' => 'ID', ) ), array( @@ -455,7 +455,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Ten - * + * * Tests "orderby" and "order" where arguments. */ $variables = array( 'orderby' => 'USERNAME', 'order' => 'ASC' ); @@ -489,7 +489,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { public function testCustomerToOrdersConnection() { $this->order_1 = $this->order_helper->create( array( 'customer_id' => $this->customer ) ); $this->order_2 = $this->order_helper->create( array( 'customer_id' => $this->new_customer ) ); - + $query = ' query { customer { @@ -504,7 +504,7 @@ class CustomerQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Query for authenticated customer's orders. */ $this->set_user( $this->customer ); diff --git a/tests/wpunit/DownloadableItemQueriesTest.php b/tests/wpunit/DownloadableItemQueriesTest.php index 6df15b8a..b34cfc1b 100644 --- a/tests/wpunit/DownloadableItemQueriesTest.php +++ b/tests/wpunit/DownloadableItemQueriesTest.php @@ -53,7 +53,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase // Force download permission updated. wc_downloadable_product_permissions( $order_id, true ); - + $query = ' query { customer { @@ -67,7 +67,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase downloadsRemaining name product { - productId + databaseId } download { downloadId @@ -82,7 +82,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase /** * Assertion One - * + * * tests query results */ $this->set_user( $this->customer ); @@ -107,7 +107,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase $this->assertEquals( $expected, $actual ); } - + public function testOrderToDownloadableItemsQueryArgs() { $valid_product = $this->products->create_simple( array( @@ -165,7 +165,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase downloadableItems(where: $input) { nodes { product { - productId + databaseId } } } @@ -177,7 +177,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase /** * Assertion One - * + * * tests "active" whereArg */ $this->set_user( $this->customer ); @@ -196,7 +196,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase 'downloadableItems' => array( 'nodes' => array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array( $valid_product, $downloadable_product ) ), @@ -212,10 +212,10 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase codecept_debug( $actual ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Two - * + * * tests "active" whereArg reversed */ $actual = graphql( @@ -233,7 +233,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase 'downloadableItems' => array( 'nodes' => array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array( $downloaded_product ) ), @@ -249,10 +249,10 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase codecept_debug( $actual ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Three - * + * * tests "hasDownloadsRemaining" whereArg */ $actual = graphql( @@ -270,7 +270,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase 'downloadableItems' => array( 'nodes' => array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array( $valid_product, $downloadable_product ) ), @@ -286,10 +286,10 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase codecept_debug( $actual ); $this->assertEquals( $expected, $actual ); - + /** * Assertion Four - * + * * tests "hasDownloadsRemaining" whereArg reversed */ $actual = graphql( @@ -307,7 +307,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase 'downloadableItems' => array( 'nodes' => array_map( function( $product_id ) { - return array( 'product' => array( 'productId' => $product_id ) ); + return array( 'product' => array( 'databaseId' => $product_id ) ); }, array( $downloaded_product ) ), @@ -349,7 +349,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase // Force download permission updated. wc_downloadable_product_permissions( $order_id, true ); - + $query = ' query { customer { @@ -361,7 +361,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase downloadsRemaining name product { - productId + databaseId } download { downloadId @@ -374,7 +374,7 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase /** * Assertion One - * + * * tests query results */ $this->set_user( $this->customer ); @@ -393,4 +393,4 @@ class DownloadableItemQueriesTest extends \Codeception\TestCase\WPTestCase $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +} diff --git a/tests/wpunit/OrderItemQueriesTest.php b/tests/wpunit/OrderItemQueriesTest.php index d483dade..2989e771 100644 --- a/tests/wpunit/OrderItemQueriesTest.php +++ b/tests/wpunit/OrderItemQueriesTest.php @@ -9,7 +9,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { private $order; private $item_helper; private $order_helper; - + public function setUp() { parent::setUp(); @@ -33,13 +33,13 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $order = new WC_Order( $this->order ); $coupon_lines = $order->get_items( 'coupon' ); $id = Relay::toGlobalId( 'shop_order', $this->order ); - + $query = ' query ($id: ID!) { order(id: $id) { couponLines { nodes { - itemId + databaseId orderId code discount @@ -55,7 +55,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query and results */ wp_set_current_user( $this->shop_manager ); @@ -69,7 +69,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -80,7 +80,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { ); }, $coupon_lines - ) + ) ), ) ), @@ -98,13 +98,13 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $order = new WC_Order( $this->order ); $fee_lines = $order->get_items( 'fee' ); $id = Relay::toGlobalId( 'shop_order', $this->order ); - + $query = ' query ($id: ID!) { order(id: $id) { feeLines { nodes { - itemId + databaseId orderId amount name @@ -120,7 +120,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query and results */ wp_set_current_user( $this->shop_manager ); @@ -134,14 +134,14 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'amount' => $item->get_amount(), 'name' => $item->get_name(), 'taxStatus' => strtoupper( $item->get_tax_status() ), 'total' => $item->get_total(), 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -164,13 +164,13 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $order = new WC_Order( $this->order ); $shipping_lines = $order->get_items( 'shipping' ); $id = Relay::toGlobalId( 'shop_order', $this->order ); - + $query = ' query ($id: ID!) { order(id: $id) { shippingLines { nodes { - itemId + databaseId orderId methodTitle total @@ -184,7 +184,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query and results */ wp_set_current_user( $this->shop_manager ); @@ -199,7 +199,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'methodTitle' => $item->get_method_title(), 'total' => $item->get_total(), @@ -232,7 +232,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $order = new WC_Order( $this->order ); $tax_lines = $order->get_items( 'tax' ); $id = Relay::toGlobalId( 'shop_order', $this->order ); - + $query = ' query ($id: ID!) { order(id: $id) { @@ -244,7 +244,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { shippingTaxTotal isCompound taxRate { - rateId + databaseId } } } @@ -254,7 +254,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query and results */ wp_set_current_user( $this->shop_manager ); @@ -273,7 +273,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $tax_lines @@ -294,7 +294,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $order = new WC_Order( $this->order ); $line_items = $order->get_items(); $id = Relay::toGlobalId( 'shop_order', $this->order ); - + $query = ' query ($id: ID!) { order(id: $id) { @@ -331,7 +331,7 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query and results */ wp_set_current_user( $this->shop_manager ); @@ -378,4 +378,4 @@ class OrderItemQueriesTest extends \Codeception\TestCase\WPTestCase { $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +} diff --git a/tests/wpunit/OrderMutationsTest.php b/tests/wpunit/OrderMutationsTest.php index 6e89c5b9..d06b89a0 100644 --- a/tests/wpunit/OrderMutationsTest.php +++ b/tests/wpunit/OrderMutationsTest.php @@ -19,7 +19,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { $this->variation = $this->getModule('\Helper\Wpunit')->product_variation(); $this->cart = $this->getModule('\Helper\Wpunit')->cart(); $this->tax = $this->getModule('\Helper\Wpunit')->tax_rate(); - + // Turn on tax calculations. Important! update_option( 'woocommerce_prices_include_tax', 'no' ); update_option( 'woocommerce_calc_taxes', 'yes' ); @@ -56,7 +56,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { clientMutationId order { id - orderId + databaseId currency orderVersion date @@ -127,7 +127,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { downloadsRemaining name product { - productId + databaseId } download { downloadId @@ -138,7 +138,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { needsProcessing couponLines { nodes { - itemId + databaseId orderId code discount @@ -150,7 +150,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { } feeLines { nodes { - itemId + databaseId orderId amount name @@ -162,7 +162,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { } shippingLines { nodes { - itemId + databaseId orderId methodTitle total @@ -178,7 +178,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { shippingTaxTotal isCompound taxRate { - rateId + databaseId } } } @@ -267,11 +267,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array( 'productId' => $product_ids[0], 'quantity' => 5, - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_product_key', 'value' => 'test product value', - ), + ), ), ), array( @@ -299,18 +299,18 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxClass' => 'STANDARD', ), ), - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_key', 'value' => 'test value', - ), + ), ), 'isPaid' => true, ); /** * Assertion One - * + * * User without necessary capabilities cannot create order an order. */ wp_set_current_user( $this->customer ); @@ -323,7 +323,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test mutation and input. */ wp_set_current_user( $this->shop_manager ); @@ -336,7 +336,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { $this->assertArrayHasKey('createOrder', $actual['data'] ); $this->assertArrayHasKey('order', $actual['data']['createOrder'] ); $this->assertArrayHasKey('id', $actual['data']['createOrder']['order'] ); - $order = \WC_Order_Factory::get_order( $actual['data']['createOrder']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $actual['data']['createOrder']['order']['databaseId'] ); $expected = array( 'data' => array( @@ -350,7 +350,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -361,7 +361,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { ); }, $order->get_items( 'coupon' ) - ) + ) ), ), 'feeLines' => array( @@ -369,14 +369,14 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'amount' => $item->get_amount(), 'name' => $item->get_name(), 'taxStatus' => strtoupper( $item->get_tax_status() ), 'total' => $item->get_total(), 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -389,9 +389,9 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'nodes' => array_reverse( array_map( function( $item ) { - + return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'methodTitle' => $item->get_method_title(), 'total' => $item->get_total(), @@ -419,7 +419,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -511,11 +511,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array( 'productId' => $product_ids[0], 'quantity' => 5, - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_product_key', 'value' => 'test product value', - ), + ), ), ), array( @@ -543,11 +543,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxClass' => 'STANDARD', ), ), - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_key', 'value' => 'test value', - ), + ), ), 'isPaid' => false, ); @@ -560,7 +560,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { codecept_debug( $initial_response ); // Retrieve order and items - $order = \WC_Order_Factory::get_order( $initial_response['data']['createOrder']['order']['orderId'] ); + $order = \WC_Order_Factory::get_order( $initial_response['data']['createOrder']['order']['databaseId'] ); $line_items = $order->get_items(); $shipping_lines = $order->get_items( 'shipping' ); $fee_lines = $order->get_items( 'fee' ); @@ -584,11 +584,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'id' => array_keys( $line_items )[0], 'quantity' => 6, - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_product_key', 'value' => 'updated test product value', - ), + ), ), ), array( @@ -617,18 +617,18 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxClass' => 'STANDARD', ), ), - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_key', 'value' => 'new test value', - ), + ), ), 'isPaid' => true, ); /** * Assertion One - * + * * User without necessary capabilities cannot update order an order. */ wp_set_current_user( $this->customer ); @@ -645,7 +645,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test mutation and input. */ wp_set_current_user( $this->shop_manager ); @@ -673,7 +673,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'code' => $item->get_code(), 'discount' => ! empty( $item->get_discount() ) ? $item->get_discount() : null, @@ -684,7 +684,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { ); }, $order->get_items( 'coupon' ) - ) + ) ), ), 'feeLines' => array( @@ -692,14 +692,14 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array_map( function( $item ) { return array( - 'itemId' => $item->get_id(), + 'databaseId'=> $item->get_id(), 'orderId' => $item->get_order_id(), 'amount' => ! empty( $item->get_amount() ) ? $item->get_amount() : null, 'name' => $item->get_name(), 'taxStatus' => strtoupper( $item->get_tax_status() ), 'total' => $item->get_total(), 'totalTax' => ! empty( $item->get_total_tax() ) ? $item->get_total_tax() : null, - 'taxClass' => ! empty( $item->get_tax_class() ) + 'taxClass' => ! empty( $item->get_tax_class() ) ? WPEnumType::get_safe_name( $item->get_tax_class() ) : 'STANDARD', ); @@ -712,9 +712,9 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'nodes' => array_reverse( array_map( function( $item ) { - + return array( - 'itemId' => $item->get_id(), + 'databaseId' => $item->get_id(), 'orderId' => $item->get_order_id(), 'methodTitle' => $item->get_method_title(), 'total' => $item->get_total(), @@ -742,7 +742,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxTotal' => $item->get_tax_total(), 'shippingTaxTotal' => $item->get_shipping_tax_total(), 'isCompound' => $item->is_compound(), - 'taxRate' => array( 'rateId' => $item->get_rate_id() ), + 'taxRate' => array( 'databaseId' => $item->get_rate_id() ), ); }, $order->get_items( 'tax' ) @@ -835,11 +835,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array( 'productId' => $product_ids[0], 'quantity' => 5, - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_product_key', 'value' => 'test product value', - ), + ), ), ), array( @@ -867,11 +867,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxClass' => 'STANDARD', ), ), - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_key', 'value' => 'test value', - ), + ), ), 'isPaid' => false, ); @@ -887,7 +887,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { $this->getModule('\Helper\Wpunit')->clear_loader_cache( 'wc_cpt' ); // Retrieve order and items - $order_id = $initial_response['data']['createOrder']['order']['orderId']; + $order_id = $initial_response['data']['createOrder']['order']['databaseId']; $order = \WC_Order_Factory::get_order( $order_id ); $line_items = $order->get_items(); $shipping_lines = $order->get_items( 'shipping' ); @@ -904,7 +904,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * User without necessary capabilities cannot delete order an order. */ wp_set_current_user( $this->customer ); @@ -921,7 +921,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test mutation and input. */ wp_set_current_user( $this->shop_manager ); @@ -933,7 +933,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { // use --debug flag to view. codecept_debug( $actual ); - + $this->assertArrayHasKey( 'data', $actual ); $this->assertArrayHasKey( 'deleteOrder', $actual['data'] ); $this->assertEquals( $initial_response['data']['createOrder'], $actual['data']['deleteOrder'] ); @@ -986,11 +986,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { array( 'productId' => $product_ids[0], 'quantity' => 5, - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_product_key', 'value' => 'test product value', - ), + ), ), ), array( @@ -1018,11 +1018,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { 'taxClass' => 'STANDARD', ), ), - 'metaData' => array( - array( + 'metaData' => array( + array( 'key' => 'test_key', 'value' => 'test value', - ), + ), ), 'isPaid' => false, ); @@ -1038,7 +1038,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { $this->getModule('\Helper\Wpunit')->clear_loader_cache( 'wc_cpt' ); // Retrieve order and items - $order_id = $initial_response['data']['createOrder']['order']['orderId']; + $order_id = $initial_response['data']['createOrder']['order']['databaseId']; $order = \WC_Order_Factory::get_order( $order_id ); $line_items = $order->get_items(); $shipping_lines = $order->get_items( 'shipping' ); @@ -1049,7 +1049,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { // Create DeleteOrderInput. $deleted_items_input = array( 'clientMutationId' => 'someId', - 'orderId' => $order->get_id(), + 'orderId' => $order->get_id(), 'itemIds' => array( current( $line_items )->get_id(), current( $coupon_lines )->get_id(), @@ -1058,7 +1058,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * User without necessary capabilities cannot delete order an order. */ wp_set_current_user( $this->customer ); @@ -1075,7 +1075,7 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test mutation and input. */ wp_set_current_user( $this->shop_manager ); @@ -1087,11 +1087,11 @@ class OrderMutationsTest extends \Codeception\TestCase\WPTestCase { // use --debug flag to view. codecept_debug( $actual ); - + $this->assertArrayHasKey( 'data', $actual ); $this->assertArrayHasKey( 'deleteOrderItems', $actual['data'] ); $this->assertEquals( $initial_response['data']['createOrder'], $actual['data']['deleteOrderItems'] ); $this->assertFalse( \WC_Order_Factory::get_order_item( current( $line_items ) ) ); $this->assertFalse( \WC_Order_Factory::get_order_item( current( $coupon_lines ) ) ); } -} \ No newline at end of file +} diff --git a/tests/wpunit/OrderQueriesTest.php b/tests/wpunit/OrderQueriesTest.php index df27a269..bc1f9627 100644 --- a/tests/wpunit/OrderQueriesTest.php +++ b/tests/wpunit/OrderQueriesTest.php @@ -35,7 +35,7 @@ class OrderQueriesTest extends \Codeception\TestCase\WPTestCase { query ($id: ID!) { order(id: $id) { id - orderId + databaseId currency orderVersion date @@ -106,7 +106,7 @@ class OrderQueriesTest extends \Codeception\TestCase\WPTestCase { downloadsRemaining name product { - productId + databaseId } download { downloadId diff --git a/tests/wpunit/ProductQueriesTest.php b/tests/wpunit/ProductQueriesTest.php index cb55edd0..53d48226 100644 --- a/tests/wpunit/ProductQueriesTest.php +++ b/tests/wpunit/ProductQueriesTest.php @@ -60,7 +60,7 @@ class ProductQueriesTest extends \Codeception\TestCase\WPTestCase { product(id: $id) { ... on SimpleProduct { id - productId + databaseId name slug date diff --git a/tests/wpunit/ProductVariationQueriesTest.php b/tests/wpunit/ProductVariationQueriesTest.php index 8ce5ec78..7f60e6d1 100644 --- a/tests/wpunit/ProductVariationQueriesTest.php +++ b/tests/wpunit/ProductVariationQueriesTest.php @@ -32,7 +32,7 @@ class ProductVariationQueriesTest extends \Codeception\TestCase\WPTestCase { query ($id: ID, $idType: ProductVariationIdTypeEnum) { productVariation(id: $id, idType: $idType) { id - variationId + databaseId name date modified diff --git a/tests/wpunit/RefundQueriesTest.php b/tests/wpunit/RefundQueriesTest.php index 45a08bfc..5bc3bf5c 100644 --- a/tests/wpunit/RefundQueriesTest.php +++ b/tests/wpunit/RefundQueriesTest.php @@ -37,7 +37,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { query ( $id: ID! ) { refund( id: $id ) { id - refundId + databaseId title reason amount @@ -50,7 +50,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Test query and failed results for users lacking required caps */ wp_set_current_user( $this->customer ); @@ -77,7 +77,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test query and results for users with required caps */ wp_set_current_user( $this->shop_manager ); @@ -113,7 +113,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Test query and "id" argument */ wp_set_current_user( $this->customer ); @@ -136,7 +136,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test query and "refundId" argument */ $variables = array( @@ -180,7 +180,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * Test query and failed results for users lacking required caps */ wp_set_current_user( $this->customer ); @@ -194,7 +194,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * Test query and results for users with required caps */ wp_set_current_user( $this->shop_manager ); @@ -214,7 +214,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * Test "statuses" where argument results should be empty * Note: This argument is functionally useless Refunds' "post_status" is always set to "completed". */ @@ -248,7 +248,7 @@ class RefundQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Four - * + * * Test "orderIn" where argument */ $variables = array( 'orderIn' => array( $this->order ) ); diff --git a/tests/wpunit/ShippingMethodQueriesTest.php b/tests/wpunit/ShippingMethodQueriesTest.php index d3eabcb1..cfc744c8 100644 --- a/tests/wpunit/ShippingMethodQueriesTest.php +++ b/tests/wpunit/ShippingMethodQueriesTest.php @@ -31,7 +31,7 @@ class ShippingMethodQueriesTest extends \Codeception\TestCase\WPTestCase { query( $id: ID!, $idType: ShippingMethodIdTypeEnum ) { shippingMethod( id: $id, idType: $idType ) { id - methodId + databaseId title description } @@ -40,7 +40,7 @@ class ShippingMethodQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * test "ID" ID type. */ $variables = array( @@ -62,7 +62,7 @@ class ShippingMethodQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * test "DATABASE_ID" ID type. */ $variables = array( @@ -86,7 +86,7 @@ class ShippingMethodQueriesTest extends \Codeception\TestCase\WPTestCase { public function testShippingMethodsQuery() { $wc_shipping = WC_Shipping::instance(); - $methods = array_values( + $methods = array_values( array_map( function( $method ) { return array( 'id' => Relay::toGlobalId( 'shipping_method', $method->id ) ); @@ -107,7 +107,7 @@ class ShippingMethodQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query */ $actual = do_graphql_request( $query, 'shippingMethodQuery' ); diff --git a/tests/wpunit/TaxRateQueriesTest.php b/tests/wpunit/TaxRateQueriesTest.php index 7eee675d..e6cb796e 100644 --- a/tests/wpunit/TaxRateQueriesTest.php +++ b/tests/wpunit/TaxRateQueriesTest.php @@ -31,7 +31,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { query taxRateQuery( $id: ID, $rateId: Int ) { taxRate( id: $id, rateId: $rateId ) { id - rateId + databaseId country state postcode @@ -49,7 +49,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query, "id" query arg, and results */ $variables = array( 'id' => $id ); @@ -63,7 +63,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * tests query, "rateId" query arg, and results */ $variables = array( 'rateId' => $this->rate ); @@ -121,7 +121,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * tests query */ $actual = graphql( array( 'query' => $query ) ); @@ -145,7 +145,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Two - * + * * tests "class" where arg */ $variables = array( 'class' => 'REDUCED_RATE' ); @@ -183,7 +183,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Three - * + * * tests "postCode" where arg */ $variables = array( 'postCode' => '23451' ); @@ -213,7 +213,7 @@ class TaxRateQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion Four - * + * * tests "postCodeIn" where arg */ $variables = array( 'postCodeIn' => array( '123456', '23451' ) ); diff --git a/tests/wpunit/VariationAttributeQueriesTest.php b/tests/wpunit/VariationAttributeQueriesTest.php index 3e86e7b3..3510f243 100644 --- a/tests/wpunit/VariationAttributeQueriesTest.php +++ b/tests/wpunit/VariationAttributeQueriesTest.php @@ -46,7 +46,7 @@ class VariationAttributeQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * test query and results */ $variables = array( 'id' => $this->variation->to_relay_id( $this->variation_id ) ); @@ -87,7 +87,7 @@ class VariationAttributeQueriesTest extends \Codeception\TestCase\WPTestCase { /** * Assertion One - * + * * test query and results */ $variables = array( 'id' => $this->product->to_relay_id( $this->product_id ) ); @@ -107,4 +107,4 @@ class VariationAttributeQueriesTest extends \Codeception\TestCase\WPTestCase { $this->assertEquals( $expected, $actual ); } -} \ No newline at end of file +}