diff --git a/codeception.dist.yml b/codeception.dist.yml index 62a0f351..0935e056 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -67,6 +67,10 @@ modules: WPLoader: wpRootFolder: '%WP_CORE_DIR%' dbUrl: 'mysql://%DB_USER%:%DB_PASSWORD%@%DB_HOST%:%DB_PORT%/%DB_NAME%' + dbName: '%DB_NAME%' + dbHost: '%DB_HOST%' + dbUser: '%DB_USER%' + dbPassword: '%DB_PASSWORD%' tablePrefix: '%WP_TABLE_PREFIX%' domain: '%WORDPRESS_DOMAIN%' adminEmail: '%ADMIN_EMAIL%' diff --git a/includes/class-core-schema-filters.php b/includes/class-core-schema-filters.php index 58ba0a39..c2ec76ef 100644 --- a/includes/class-core-schema-filters.php +++ b/includes/class-core-schema-filters.php @@ -123,6 +123,7 @@ public static function add_filters() { public static function register_post_types( $args, $post_type ) { if ( 'product' === $post_type ) { $args['show_in_graphql'] = true; + $args['model'] = \WPGraphQL\WooCommerce\Model\Product::class; $args['graphql_single_name'] = 'Product'; $args['graphql_plural_name'] = 'Products'; $args['graphql_kind'] = 'interface'; @@ -358,6 +359,7 @@ public static function inject_union_type_resolver( $type, $value, $wp_union ) { * @return \WPGraphQL\Type\WPObjectType|null */ public static function inject_type_resolver( $type, $value ) { + $type_registry = \WPGraphQL::get_type_registry(); switch ( $type ) { case 'Coupon': @@ -367,6 +369,9 @@ public static function inject_type_resolver( $type, $value ) { $type = $type_registry->get_type( $new_type ); } break; + case 'ProductVariation': + $type = self::resolve_product_variation_type( $value ); + break; case 'Product': $supported_types = WooGraphQL::get_enabled_product_types(); if ( in_array( $value->type, array_keys( $supported_types ), true ) ) { @@ -433,6 +438,7 @@ public static function resolve_product_variation_type( $value ) { $type_registry = \WPGraphQL::get_type_registry(); $possible_types = WooGraphQL::get_enabled_product_variation_types(); $product_type = $value->get_type(); + if ( isset( $possible_types[ $product_type ] ) ) { return $type_registry->get_type( $possible_types[ $product_type ] ); } diff --git a/includes/model/class-customer.php b/includes/model/class-customer.php index 2a6c019b..816b8f2c 100644 --- a/includes/model/class-customer.php +++ b/includes/model/class-customer.php @@ -86,7 +86,7 @@ protected function init() { }, 'id' => function () { return ( ! empty( $this->data->get_id() ) ) - ? Relay::toGlobalId( 'customer', $this->data->get_id() ) + ? Relay::toGlobalId( 'user', $this->data->get_id() ) : 'guest'; }, 'databaseId' => function () { diff --git a/includes/model/class-product-variation.php b/includes/model/class-product-variation.php index 638a0221..59120761 100644 --- a/includes/model/class-product-variation.php +++ b/includes/model/class-product-variation.php @@ -95,7 +95,7 @@ protected function init() { return ! empty( $this->wc_data->get_id() ) ? $this->wc_data->get_id() : null; }, 'id' => function () { - return ! empty( $this->ID ) ? Relay::toGlobalId( 'product_variation', "{$this->ID}" ) : null; + return ! empty( $this->ID ) ? Relay::toGlobalId( 'post', "{$this->ID}" ) : null; }, 'name' => function () { return ! empty( $this->wc_data->get_name() ) ? $this->wc_data->get_name() : null; @@ -226,7 +226,7 @@ protected function init() { return ! empty( $this->wc_data->get_parent_id() ) ? $this->wc_data->get_parent_id() : null; }, 'parentId' => function () { - return ! empty( $this->wc_data->get_parent_id() ) ? Relay::toGlobalId( 'product', (string) $this->wc_data->get_parent_id() ) : null; + return ! empty( $this->wc_data->get_parent_id() ) ? Relay::toGlobalId( 'post', (string) $this->wc_data->get_parent_id() ) : null; }, 'shipping_class_id' => function () { return ! empty( $this->wc_data->get_shipping_class_id() ) ? $this->wc_data->get_shipping_class_id() : null; diff --git a/includes/model/class-product.php b/includes/model/class-product.php index 6a1665d1..9109288e 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -196,7 +196,7 @@ protected function init() { return ! empty( $this->wc_data->get_id() ) ? $this->wc_data->get_id() : null; }, 'id' => function () { - return ! empty( $this->ID ) ? Relay::toGlobalId( 'product', "{$this->ID}" ) : null; + return ! empty( $this->ID ) ? Relay::toGlobalId( 'post', "{$this->ID}" ) : null; }, 'type' => function () { return ! empty( $this->wc_data->get_type() ) ? $this->wc_data->get_type() : null; diff --git a/includes/type/interface/class-product-variation.php b/includes/type/interface/class-product-variation.php index 07793119..7efb6c6b 100644 --- a/includes/type/interface/class-product-variation.php +++ b/includes/type/interface/class-product-variation.php @@ -50,6 +50,7 @@ public static function register_interface(): void { 'SimpleProductVariation', [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product_Variation::class, 'description' => __( 'A product variation', 'wp-graphql-woocommerce' ), 'interfaces' => [ 'Node', 'ProductVariation' ], 'fields' => [], diff --git a/includes/type/object/class-product-types.php b/includes/type/object/class-product-types.php index b6cfdb96..8630b6ad 100644 --- a/includes/type/object/class-product-types.php +++ b/includes/type/object/class-product-types.php @@ -68,6 +68,7 @@ private static function register_simple_product_type() { 'SimpleProduct', [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product::class, 'description' => __( 'A simple product object', 'wp-graphql-woocommerce' ), 'interfaces' => self::get_product_interfaces( [ @@ -92,6 +93,7 @@ private static function register_variable_product_type() { 'VariableProduct', [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product::class, 'description' => __( 'A variable product object', 'wp-graphql-woocommerce' ), 'interfaces' => self::get_product_interfaces( [ @@ -116,6 +118,7 @@ private static function register_external_product_type() { 'ExternalProduct', [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product::class, 'description' => __( 'A external product object', 'wp-graphql-woocommerce' ), 'interfaces' => self::get_product_interfaces( [ 'ProductWithPricing' ] ), 'fields' => array_merge( @@ -144,6 +147,7 @@ private static function register_group_product_type() { 'GroupProduct', [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product::class, 'description' => __( 'A group product object', 'wp-graphql-woocommerce' ), 'interfaces' => self::get_product_interfaces( [ 'ProductWithPricing' ] ), 'fields' => [ @@ -208,6 +212,7 @@ private static function register_unsupported_product_type() { WooGraphQL::get_supported_product_type(), [ 'eagerlyLoadType' => true, + 'model' => \WPGraphQL\WooCommerce\Model\Product::class, 'description' => __( 'A product object for a product type that is unsupported by the current API.', 'wp-graphql-woocommerce' ), 'interfaces' => self::get_product_interfaces( [ diff --git a/tests/_support/Helper/crud-helpers/cart.php b/tests/_support/Helper/crud-helpers/cart.php index efeab272..004f2779 100644 --- a/tests/_support/Helper/crud-helpers/cart.php +++ b/tests/_support/Helper/crud-helpers/cart.php @@ -119,7 +119,7 @@ public function print_item_query( $key ) { 'key' => $item['key'], 'product' => array( 'node' => array( - 'id' => Relay::toGlobalId( 'product', $item['product_id'] ), + 'id' => Relay::toGlobalId( 'post', $item['product_id'] ), 'databaseId' => $item['product_id'], ), ), @@ -127,7 +127,7 @@ public function print_item_query( $key ) { ? array( 'attributes' => $attributes, 'node' => array( - 'id' => Relay::toGlobalId( 'product_variation', $item['variation_id'] ), + 'id' => Relay::toGlobalId( 'post', $item['variation_id'] ), 'databaseId' => $item['variation_id'], ), ) diff --git a/tests/_support/Helper/crud-helpers/customer.php b/tests/_support/Helper/crud-helpers/customer.php index 29577545..ae8f05b7 100644 --- a/tests/_support/Helper/crud-helpers/customer.php +++ b/tests/_support/Helper/crud-helpers/customer.php @@ -10,7 +10,7 @@ public function __construct() { } public function to_relay_id( $id ) { - return Relay::toGlobalId( 'customer', $id ); + return Relay::toGlobalId( 'user', $id ); } public function create( $args = array() ) { diff --git a/tests/_support/Helper/crud-helpers/order.php b/tests/_support/Helper/crud-helpers/order.php index ecd220f8..01b0fd9c 100644 --- a/tests/_support/Helper/crud-helpers/order.php +++ b/tests/_support/Helper/crud-helpers/order.php @@ -205,7 +205,7 @@ public function print_query( $id ) { 'pricesIncludeTax' => $data->get_prices_include_tax(), 'parent' => null, 'customer' => ! empty( $data->get_customer_id() ) - ? array( 'id' => Relay::toGlobalId( 'customer', $data->get_customer_id() ) ) + ? array( 'id' => Relay::toGlobalId( 'user', $data->get_customer_id() ) ) : null, 'customerIpAddress' => ! empty( $data->get_customer_ip_address() ) ? $data->get_customer_ip_address() diff --git a/tests/_support/Helper/crud-helpers/product-variation.php b/tests/_support/Helper/crud-helpers/product-variation.php index 7ed33d13..8dd805f4 100644 --- a/tests/_support/Helper/crud-helpers/product-variation.php +++ b/tests/_support/Helper/crud-helpers/product-variation.php @@ -14,7 +14,7 @@ protected function __construct() { } public function to_relay_id( $id ) { - return Relay::toGlobalId( 'product_variation', $id ); + return Relay::toGlobalId( 'post', $id ); } public function reset_indexes() { diff --git a/tests/_support/Helper/crud-helpers/product.php b/tests/_support/Helper/crud-helpers/product.php index 133ac71c..2ec34321 100644 --- a/tests/_support/Helper/crud-helpers/product.php +++ b/tests/_support/Helper/crud-helpers/product.php @@ -14,7 +14,7 @@ protected function __construct() { } public function to_relay_id( $id ) { - return Relay::toGlobalId( 'product', $id ); + return Relay::toGlobalId( 'post', $id ); } public function reset_indexes() { diff --git a/tests/_support/TestCase/WooGraphQLTestCase.php b/tests/_support/TestCase/WooGraphQLTestCase.php index 15420eb3..d03c2c71 100644 --- a/tests/_support/TestCase/WooGraphQLTestCase.php +++ b/tests/_support/TestCase/WooGraphQLTestCase.php @@ -115,7 +115,13 @@ protected function logout() { * * @return mixed */ - protected function maybe( $possible, $default = self::IS_NULL ) { + protected function maybe( $possible, $custom_default = null ) { + if ( null === $custom_default ) { + $default = static::IS_NULL; + } else { + $default = $custom_default; + } + if ( is_array( $possible ) && 2 === count( $possible ) ) { list( $possible, $decorated ) = $possible; } else { diff --git a/tests/wpunit/CartMutationsTest.php b/tests/wpunit/CartMutationsTest.php index af51deed..ff892b1f 100644 --- a/tests/wpunit/CartMutationsTest.php +++ b/tests/wpunit/CartMutationsTest.php @@ -58,7 +58,7 @@ public function testAddToCartMutationWithProduct() { [ $this->expectedField( 'addToCart.clientMutationId', 'someId' ), $this->expectedField( 'addToCart.cartItem.key', $cart_item_key ), - $this->expectedField( 'addToCart.cartItem.product.node.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'addToCart.cartItem.product.node.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedField( 'addToCart.cartItem.quantity', 2 ), $this->expectedField( 'addToCart.cartItem.subtotal', wc_graphql_price( $cart_item['line_subtotal'] ) ), $this->expectedField( 'addToCart.cartItem.subtotalTax', wc_graphql_price( $cart_item['line_subtotal_tax'] ) ), @@ -131,8 +131,8 @@ public function testAddToCartMutationWithProductVariation() { [ $this->expectedField( 'addToCart.clientMutationId', 'someId' ), $this->expectedField( 'addToCart.cartItem.key', $cart_item_key ), - $this->expectedField( 'addToCart.cartItem.product.node.id', $this->toRelayId( 'product', $ids['product'] ) ), - $this->expectedField( 'addToCart.cartItem.variation.node.id', $this->toRelayId( 'product_variation', $ids['variations'][0] ) ), + $this->expectedField( 'addToCart.cartItem.product.node.id', $this->toRelayId( 'post', $ids['product'] ) ), + $this->expectedField( 'addToCart.cartItem.variation.node.id', $this->toRelayId( 'post', $ids['variations'][0] ) ), $this->expectedField( 'addToCart.cartItem.quantity', 3 ), $this->expectedField( 'addToCart.cartItem.subtotal', wc_graphql_price( $cart_item['line_subtotal'] ) ), $this->expectedField( 'addToCart.cartItem.subtotalTax', wc_graphql_price( $cart_item['line_subtotal_tax'] ) ), @@ -444,7 +444,7 @@ public function testEmptyCartMutation() { 'key' => $cart_item['key'], 'product' => [ 'node' => [ - 'id' => $this->toRelayId( 'product', $cart_item['product_id'] ), + 'id' => $this->toRelayId( 'post', $cart_item['product_id'] ), ], ], 'variation' => null, @@ -541,7 +541,7 @@ public function testApplyCouponMutation() { 'key' => $cart_item['key'], 'product' => [ 'node' => [ - 'id' => $this->toRelayId( 'product', $cart_item['product_id'] ), + 'id' => $this->toRelayId( 'post', $cart_item['product_id'] ), ], ], 'quantity' => $cart_item['quantity'], @@ -720,7 +720,7 @@ public function testRemoveCouponMutation() { 'key' => $cart_item['key'], 'product' => [ 'node' => [ - 'id' => $this->toRelayId( 'product', $cart_item['product_id'] ), + 'id' => $this->toRelayId( 'post', $cart_item['product_id'] ), ], ], 'quantity' => $cart_item['quantity'], @@ -1204,7 +1204,7 @@ public function testFillCartMutationAndErrors() { [ $this->expectedField( 'product.node.databaseId', $product_one ), $this->expectedField( 'quantity', 3 ), - $this->expectedField( 'variation', self::IS_NULL ), + $this->expectedField( 'variation', static::IS_NULL ), ] ), $this->expectedNode( @@ -1212,7 +1212,7 @@ public function testFillCartMutationAndErrors() { [ $this->expectedField( 'product.node.databaseId', $product_two ), $this->expectedField( 'quantity', 2 ), - $this->expectedField( 'variation', self::IS_NULL ), + $this->expectedField( 'variation', static::IS_NULL ), ] ), ] diff --git a/tests/wpunit/CartQueriesTest.php b/tests/wpunit/CartQueriesTest.php index 4bb44c0c..312d333c 100644 --- a/tests/wpunit/CartQueriesTest.php +++ b/tests/wpunit/CartQueriesTest.php @@ -24,18 +24,18 @@ public function getExpectedCartData() { $this->expectedField( 'cart.isEmpty', $cart->is_empty() ), $this->expectedField( 'cart.displayPricesIncludeTax', $cart->display_prices_including_tax() ), $this->expectedField( 'cart.needsShippingAddress', $cart->needs_shipping_address() ), - $this->expectedField( 'cart.rawSubtotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawSubtotalTax', self::NOT_NULL ), - $this->expectedField( 'cart.rawDiscountTotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawDiscountTax', self::NOT_NULL ), - $this->expectedField( 'cart.rawShippingTotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawShippingTax', self::NOT_NULL ), - $this->expectedField( 'cart.rawContentsTotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawContentsTax', self::NOT_NULL ), - $this->expectedField( 'cart.rawFeeTotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawFeeTax', self::NOT_NULL ), - $this->expectedField( 'cart.rawtotal', self::NOT_NULL ), - $this->expectedField( 'cart.rawTotalTax', self::NOT_NULL ), + $this->expectedField( 'cart.rawSubtotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawSubtotalTax', static::NOT_NULL ), + $this->expectedField( 'cart.rawDiscountTotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawDiscountTax', static::NOT_NULL ), + $this->expectedField( 'cart.rawShippingTotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawShippingTax', static::NOT_NULL ), + $this->expectedField( 'cart.rawContentsTotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawContentsTax', static::NOT_NULL ), + $this->expectedField( 'cart.rawFeeTotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawFeeTax', static::NOT_NULL ), + $this->expectedField( 'cart.rawtotal', static::NOT_NULL ), + $this->expectedField( 'cart.rawTotalTax', static::NOT_NULL ), ]; } @@ -47,12 +47,12 @@ public function getExpectedCartItemData( $path, $cart_item_key ) { $path, [ $this->expectedField( 'key', $item['key'] ), - $this->expectedField( 'product.node.id', $this->toRelayId( 'product', $item['product_id'] ) ), + $this->expectedField( 'product.node.id', $this->toRelayId( 'post', $item['product_id'] ) ), $this->expectedField( 'product.node.databaseId', $item['product_id'] ), $this->expectedField( 'variation.node.id', ! empty( $item['variation_id'] ) - ? $this->toRelayId( 'product_variation', $item['variation_id'] ) + ? $this->toRelayId( 'post', $item['variation_id'] ) : 'NULL' ), $this->expectedField( diff --git a/tests/wpunit/CheckoutMutationTest.php b/tests/wpunit/CheckoutMutationTest.php index 5faf2d53..3ac4b089 100644 --- a/tests/wpunit/CheckoutMutationTest.php +++ b/tests/wpunit/CheckoutMutationTest.php @@ -351,7 +351,7 @@ public function testCheckoutMutation() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'checkout.order.id', self::NOT_NULL ), + $this->expectedField( 'checkout.order.id', static::NOT_NULL ), $this->expectedField( 'checkout.order.status', 'ON_HOLD' ), $this->expectedNode( 'checkout.order.metaData', @@ -364,98 +364,98 @@ public function testCheckoutMutation() { 'checkout.order.couponLines.nodes', [ $this->expectedField( 'code', $coupon->get_code() ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'discount', self::NOT_NULL ), - $this->expectedField( 'discountTax', self::NOT_NULL ), - $this->expectedField( 'coupon', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'discount', static::NOT_NULL ), + $this->expectedField( 'discountTax', static::NOT_NULL ), + $this->expectedField( 'coupon', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.feeLines.nodes', [ $this->expectedField( 'name', 'Surcharge' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'amount', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'amount', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.shippingLines.nodes', [ $this->expectedField( 'methodTitle', 'Flat rate' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.taxLines.nodes', [ $this->expectedField( 'label', 'VAT' ), - $this->expectedField( 'rateCode', self::NOT_NULL ), - $this->expectedField( 'taxTotal', self::NOT_NULL ), - $this->expectedField( 'shippingTaxTotal', self::NOT_NULL ), - $this->expectedField( 'isCompound', self::NOT_NULL ), - $this->expectedField( 'taxRate', self::NOT_NULL ), + $this->expectedField( 'rateCode', static::NOT_NULL ), + $this->expectedField( 'taxTotal', static::NOT_NULL ), + $this->expectedField( 'shippingTaxTotal', static::NOT_NULL ), + $this->expectedField( 'isCompound', static::NOT_NULL ), + $this->expectedField( 'taxRate', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[0] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[1] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[2] ), - $this->expectedField( 'variationId', self::NOT_NULL ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), - $this->expectedField( 'variation.node.id', self::NOT_NULL ), + $this->expectedField( 'variationId', static::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), + $this->expectedField( 'variation.node.id', static::NOT_NULL ), ] ), $this->expectedField( 'checkout.customer.id', - $this->toRelayId( 'customer', $this->customer ) + $this->toRelayId( 'user', $this->customer ) ), $this->expectedField( 'checkout.result', 'success' ), - $this->expectedField( 'checkout.redirect', self::NOT_NULL ), + $this->expectedField( 'checkout.redirect', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -510,7 +510,7 @@ public function testCheckoutMutationWithNewAccount() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'checkout.order.id', self::NOT_NULL ), + $this->expectedField( 'checkout.order.id', static::NOT_NULL ), $this->expectedField( 'checkout.order.status', 'ON_HOLD' ), $this->expectedNode( 'checkout.order.metaData', @@ -523,84 +523,84 @@ public function testCheckoutMutationWithNewAccount() { 'checkout.order.feeLines.nodes', [ $this->expectedField( 'name', 'Surcharge' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'amount', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'amount', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.shippingLines.nodes', [ $this->expectedField( 'methodTitle', 'Flat rate' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.taxLines.nodes', [ $this->expectedField( 'label', 'VAT' ), - $this->expectedField( 'rateCode', self::NOT_NULL ), - $this->expectedField( 'taxTotal', self::NOT_NULL ), - $this->expectedField( 'shippingTaxTotal', self::NOT_NULL ), - $this->expectedField( 'isCompound', self::NOT_NULL ), - $this->expectedField( 'taxRate', self::NOT_NULL ), + $this->expectedField( 'rateCode', static::NOT_NULL ), + $this->expectedField( 'taxTotal', static::NOT_NULL ), + $this->expectedField( 'shippingTaxTotal', static::NOT_NULL ), + $this->expectedField( 'isCompound', static::NOT_NULL ), + $this->expectedField( 'taxRate', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[0] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[1] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[2] ), - $this->expectedField( 'variationId', self::NOT_NULL ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), - $this->expectedField( 'variation.node.id', self::NOT_NULL ), + $this->expectedField( 'variationId', static::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), + $this->expectedField( 'variation.node.id', static::NOT_NULL ), ] ), - $this->expectedField( 'checkout.customer.id', self::NOT_NULL ), + $this->expectedField( 'checkout.customer.id', static::NOT_NULL ), $this->expectedField( 'checkout.result', 'success' ), - $this->expectedField( 'checkout.redirect', self::NOT_NULL ), + $this->expectedField( 'checkout.redirect', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -652,7 +652,7 @@ public function testCheckoutMutationWithNoAccount() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'checkout.order.id', self::NOT_NULL ), + $this->expectedField( 'checkout.order.id', static::NOT_NULL ), $this->expectedField( 'checkout.order.status', 'ON_HOLD' ), $this->expectedNode( 'checkout.order.metaData', @@ -665,84 +665,84 @@ public function testCheckoutMutationWithNoAccount() { 'checkout.order.feeLines.nodes', [ $this->expectedField( 'name', 'Surcharge' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'amount', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'amount', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.shippingLines.nodes', [ $this->expectedField( 'methodTitle', 'Flat rate' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.taxLines.nodes', [ $this->expectedField( 'label', 'VAT' ), - $this->expectedField( 'rateCode', self::NOT_NULL ), - $this->expectedField( 'taxTotal', self::NOT_NULL ), - $this->expectedField( 'shippingTaxTotal', self::NOT_NULL ), - $this->expectedField( 'isCompound', self::NOT_NULL ), - $this->expectedField( 'taxRate', self::NOT_NULL ), + $this->expectedField( 'rateCode', static::NOT_NULL ), + $this->expectedField( 'taxTotal', static::NOT_NULL ), + $this->expectedField( 'shippingTaxTotal', static::NOT_NULL ), + $this->expectedField( 'isCompound', static::NOT_NULL ), + $this->expectedField( 'taxRate', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[0] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[1] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[2] ), - $this->expectedField( 'variationId', self::NOT_NULL ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), - $this->expectedField( 'variation.node.id', self::NOT_NULL ), + $this->expectedField( 'variationId', static::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), + $this->expectedField( 'variation.node.id', static::NOT_NULL ), ] ), $this->expectedField( 'checkout.customer.id', 'guest' ), $this->expectedField( 'checkout.result', 'success' ), - $this->expectedField( 'checkout.redirect', self::NOT_NULL ), + $this->expectedField( 'checkout.redirect', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -800,7 +800,7 @@ public function testCheckoutMutationWithPrepaidOrder() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'checkout.order.id', self::NOT_NULL ), + $this->expectedField( 'checkout.order.id', static::NOT_NULL ), $this->expectedField( 'checkout.order.status', 'COMPLETED' ), $this->expectedNode( 'checkout.order.metaData', @@ -813,57 +813,57 @@ public function testCheckoutMutationWithPrepaidOrder() { 'checkout.order.feeLines.nodes', [ $this->expectedField( 'name', 'Surcharge' ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'orderId', self::NOT_NULL ), - $this->expectedField( 'amount', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'orderId', static::NOT_NULL ), + $this->expectedField( 'amount', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.taxLines.nodes', [ $this->expectedField( 'label', 'VAT' ), - $this->expectedField( 'rateCode', self::NOT_NULL ), - $this->expectedField( 'taxTotal', self::NOT_NULL ), - $this->expectedField( 'shippingTaxTotal', self::NOT_NULL ), - $this->expectedField( 'isCompound', self::NOT_NULL ), - $this->expectedField( 'taxRate', self::NOT_NULL ), + $this->expectedField( 'rateCode', static::NOT_NULL ), + $this->expectedField( 'taxTotal', static::NOT_NULL ), + $this->expectedField( 'shippingTaxTotal', static::NOT_NULL ), + $this->expectedField( 'isCompound', static::NOT_NULL ), + $this->expectedField( 'taxRate', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[0] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[1] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedField( 'checkout.customer.id', 'guest' ), $this->expectedField( 'checkout.result', 'success' ), - $this->expectedField( 'checkout.redirect', self::NOT_NULL ), + $this->expectedField( 'checkout.redirect', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -1033,7 +1033,7 @@ public function testCheckoutMutationWithStripe() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'checkout.order.id', self::NOT_NULL ), + $this->expectedField( 'checkout.order.id', static::NOT_NULL ), $this->expectedField( 'checkout.order.status', 'PROCESSING' ), $this->expectedNode( 'checkout.order.metaData', @@ -1051,28 +1051,28 @@ public function testCheckoutMutationWithStripe() { 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[0] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedNode( 'checkout.order.lineItems.nodes', [ $this->expectedField( 'productId', $product_ids[1] ), - $this->expectedField( 'quantity', self::NOT_NULL ), - $this->expectedField( 'taxClass', self::NOT_NULL ), - $this->expectedField( 'subtotal', self::NOT_NULL ), - $this->expectedField( 'subtotalTax', self::NOT_NULL ), - $this->expectedField( 'total', self::NOT_NULL ), - $this->expectedField( 'totalTax', self::NOT_NULL ), - $this->expectedField( 'taxStatus', self::NOT_NULL ), - $this->expectedField( 'product.node.id', self::NOT_NULL ), + $this->expectedField( 'quantity', static::NOT_NULL ), + $this->expectedField( 'taxClass', static::NOT_NULL ), + $this->expectedField( 'subtotal', static::NOT_NULL ), + $this->expectedField( 'subtotalTax', static::NOT_NULL ), + $this->expectedField( 'total', static::NOT_NULL ), + $this->expectedField( 'totalTax', static::NOT_NULL ), + $this->expectedField( 'taxStatus', static::NOT_NULL ), + $this->expectedField( 'product.node.id', static::NOT_NULL ), ] ), $this->expectedField( 'checkout.result', 'success' ), @@ -1119,7 +1119,7 @@ public function testCheckoutMutationCartItemValidation() { * Ensure that checkout failed when stock is too low. */ $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'checkout', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'checkout', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); } diff --git a/tests/wpunit/CollectionStatsQueryTest.php b/tests/wpunit/CollectionStatsQueryTest.php index 1534b01e..48cf4989 100644 --- a/tests/wpunit/CollectionStatsQueryTest.php +++ b/tests/wpunit/CollectionStatsQueryTest.php @@ -77,7 +77,7 @@ public function testCollectionStatsQuery() { [ $this->expectedField( 'node.slug', 'red' ), $this->expectedField( 'count', 2 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), $this->expectedNode( @@ -85,7 +85,7 @@ public function testCollectionStatsQuery() { [ $this->expectedField( 'node.slug', 'blue' ), $this->expectedField( 'count', 2 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), $this->expectedNode( @@ -93,7 +93,7 @@ public function testCollectionStatsQuery() { [ $this->expectedField( 'node.slug', 'green' ), $this->expectedField( 'count', 2 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), ], @@ -228,7 +228,7 @@ public function testCollectionStatsQueryWithWhereArgs() { [ $this->expectedField( 'node.slug', 'normal' ), $this->expectedField( 'count', 20 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), $this->expectedNode( @@ -236,7 +236,7 @@ public function testCollectionStatsQueryWithWhereArgs() { [ $this->expectedField( 'node.slug', 'special' ), $this->expectedField( 'count', 10 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), ], @@ -290,7 +290,7 @@ public function testCollectionStatsQueryWithWhereArgs() { [ $this->expectedField( 'node.slug', 'special' ), $this->expectedField( 'count', 5 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), ], @@ -350,7 +350,7 @@ public function testCollectionStatsQueryWithWhereArgs() { [ $this->expectedField( 'node.slug', 'normal' ), $this->expectedField( 'count', 20 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ] ), $this @@ -489,7 +489,7 @@ public function testCollectionStatsQueryWithOrTaxQueries() { [ $this->expectedField( 'node.slug', 'normal' ), $this->expectedField( 'count', 5 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 0 ), @@ -498,7 +498,7 @@ public function testCollectionStatsQueryWithOrTaxQueries() { [ $this->expectedField( 'node.slug', 'special' ), $this->expectedField( 'count', 15 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 1 ), @@ -513,7 +513,7 @@ public function testCollectionStatsQueryWithOrTaxQueries() { [ $this->expectedField( 'node.slug', 'polka-dot' ), $this->expectedField( 'count', 6 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 0 ), @@ -522,7 +522,7 @@ public function testCollectionStatsQueryWithOrTaxQueries() { [ $this->expectedField( 'node.slug', 'striped' ), $this->expectedField( 'count', 14 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 1 ), @@ -667,7 +667,7 @@ public function testCollectionStatsQueryWithAndTaxQueries() { [ $this->expectedField( 'node.slug', 'normal' ), $this->expectedField( 'count', 3 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 0 ), @@ -676,7 +676,7 @@ public function testCollectionStatsQueryWithAndTaxQueries() { [ $this->expectedField( 'node.slug', 'special' ), $this->expectedField( 'count', 8 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 1 ), @@ -691,7 +691,7 @@ public function testCollectionStatsQueryWithAndTaxQueries() { [ $this->expectedField( 'node.slug', 'polka-dot' ), $this->expectedField( 'count', 4 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 0 ), @@ -700,7 +700,7 @@ public function testCollectionStatsQueryWithAndTaxQueries() { [ $this->expectedField( 'node.slug', 'striped' ), $this->expectedField( 'count', 8 ), - $this->expectedField( 'termId', self::NOT_FALSY ), + $this->expectedField( 'termId', static::NOT_FALSY ), ], 1 ), diff --git a/tests/wpunit/ConnectionPaginationTest.php b/tests/wpunit/ConnectionPaginationTest.php index 0c055c31..2a41d51c 100644 --- a/tests/wpunit/ConnectionPaginationTest.php +++ b/tests/wpunit/ConnectionPaginationTest.php @@ -192,7 +192,7 @@ static function ( $key_a, $key_b ) { ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'products.found', self::IS_NULL ), + $this->expectedField( 'products.found', static::IS_NULL ), $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), $this->expectedField( 'products.pageInfo.hasNextPage', false ), $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[2] ) ), @@ -234,7 +234,7 @@ static function ( $key_a, $key_b ) { ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'products.found', self::IS_NULL ), + $this->expectedField( 'products.found', static::IS_NULL ), $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), $this->expectedField( 'products.pageInfo.hasNextPage', true ), $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[1] ) ), diff --git a/tests/wpunit/CoreInterfaceQueriesTest.php b/tests/wpunit/CoreInterfaceQueriesTest.php index 23e01e54..b7d610d5 100644 --- a/tests/wpunit/CoreInterfaceQueriesTest.php +++ b/tests/wpunit/CoreInterfaceQueriesTest.php @@ -57,7 +57,7 @@ public function testProductAsNodeWithComments() { $expected = [ 'data' => [ 'product' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product', $product_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $product_id ), 'commentCount' => 1, 'commentStatus' => 'open', ], @@ -165,7 +165,7 @@ public function testProductAsNodeWithContentEditor() { $expected = [ 'data' => [ 'product' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product', $product_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $product_id ), 'content' => $product->get_description(), ], ], @@ -206,7 +206,7 @@ public function testProductAsNodeWithFeaturedImage() { $expected = [ 'data' => [ 'product' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product', $product_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $product_id ), 'featuredImageId' => \GraphQLRelay\Relay::toGlobalId( 'post', $attachment_id ), 'featuredImageDatabaseId' => $attachment_id, ], @@ -259,7 +259,7 @@ public function testProductAsContentNode() { $expected = [ 'data' => [ 'product' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product', $product_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $product_id ), 'databaseId' => $wp_product->ID, 'date' => (string) $wc_product->get_date_created(), 'dateGmt' => \WPGraphQL\Utils\Utils::prepare_date_response( $wp_product->post_date_gmt ), @@ -310,7 +310,7 @@ public function testProductAsUniformResourceIdentifiable() { $expected = [ 'data' => [ 'product' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product', $product_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $product_id ), 'uri' => str_ireplace( home_url(), '', get_permalink( $wp_product->ID ) ), ], ], @@ -366,7 +366,7 @@ public function testNodeInterfacesOnProductVariation() { $expected = [ 'data' => [ 'productVariation' => [ - 'id' => \GraphQLRelay\Relay::toGlobalId( 'product_variation', $variation_id ), + 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $variation_id ), 'databaseId' => $wp_product->ID, 'date' => (string) $wc_product->get_date_created(), 'dateGmt' => \WPGraphQL\Utils\Utils::prepare_date_response( $wp_product->post_date_gmt ), diff --git a/tests/wpunit/CouponMutationsTest.php b/tests/wpunit/CouponMutationsTest.php index 15f69772..c8e0211c 100644 --- a/tests/wpunit/CouponMutationsTest.php +++ b/tests/wpunit/CouponMutationsTest.php @@ -34,7 +34,7 @@ public function testCreateCoupon() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'createCoupon' ), - $this->expectedField( 'createCoupon', self::IS_NULL ), + $this->expectedField( 'createCoupon', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -59,8 +59,8 @@ public function testCreateCoupon() { $this->expectedObject( 'createCoupon.coupon', [ - $this->expectedField( 'id', self::NOT_FALSY ), - $this->expectedField( 'databaseId', self::NOT_FALSY ), + $this->expectedField( 'id', static::NOT_FALSY ), + $this->expectedField( 'databaseId', static::NOT_FALSY ), $this->expectedField( 'code', 'testcode' ), $this->expectedField( 'amount', 0.25 ), $this->expectedField( 'discountType', 'PERCENT' ), @@ -106,7 +106,7 @@ public function testUpdateCoupon() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'updateCoupon' ), - $this->expectedField( 'updateCoupon', self::IS_NULL ), + $this->expectedField( 'updateCoupon', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -172,7 +172,7 @@ public function testDeleteCoupon() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'deleteCoupon' ), - $this->expectedField( 'deleteCoupon', self::IS_NULL ), + $this->expectedField( 'deleteCoupon', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); diff --git a/tests/wpunit/CouponQueriesTest.php b/tests/wpunit/CouponQueriesTest.php index f2b7659d..e5fc9623 100644 --- a/tests/wpunit/CouponQueriesTest.php +++ b/tests/wpunit/CouponQueriesTest.php @@ -13,17 +13,17 @@ public function expectedCouponData( $coupon_id ) { $this->expectedField( 'coupon.modified', $coupon->get_date_modified()->__toString() ), $this->expectedField( 'coupon.discountType', strtoupper( $coupon->get_discount_type() ) ), $this->expectedField( 'coupon.description', $coupon->get_description() ), - $this->expectedField( 'coupon.dateExpiry', $this->maybe( $coupon->get_date_expires(), self::IS_NULL ) ), + $this->expectedField( 'coupon.dateExpiry', $this->maybe( $coupon->get_date_expires(), static::IS_NULL ) ), $this->expectedField( 'coupon.usageCount', $coupon->get_usage_count() ), $this->expectedField( 'coupon.individualUse', $coupon->get_individual_use() ), - $this->expectedField( 'coupon.usageLimit', $this->maybe( $coupon->get_usage_limit(), self::IS_NULL ) ), - $this->expectedField( 'coupon.usageLimitPerUser', $this->maybe( $coupon->get_usage_limit_per_user(), self::IS_NULL ) ), - $this->expectedField( 'coupon.limitUsageToXItems', $this->maybe( $coupon->get_limit_usage_to_x_items(), self::IS_NULL ) ), + $this->expectedField( 'coupon.usageLimit', $this->maybe( $coupon->get_usage_limit(), static::IS_NULL ) ), + $this->expectedField( 'coupon.usageLimitPerUser', $this->maybe( $coupon->get_usage_limit_per_user(), static::IS_NULL ) ), + $this->expectedField( 'coupon.limitUsageToXItems', $this->maybe( $coupon->get_limit_usage_to_x_items(), static::IS_NULL ) ), $this->expectedField( 'coupon.freeShipping', $coupon->get_free_shipping() ), $this->expectedField( 'coupon.excludeSaleItems', $coupon->get_exclude_sale_items() ), - $this->expectedField( 'coupon.minimumAmount', $this->maybe( $coupon->get_minimum_amount(), self::IS_NULL ) ), - $this->expectedField( 'coupon.maximumAmount', $this->maybe( $coupon->get_maximum_amount(), self::IS_NULL ) ), - $this->expectedField( 'coupon.emailRestrictions', $this->maybe( $coupon->get_email_restrictions(), self::IS_NULL ) ), + $this->expectedField( 'coupon.minimumAmount', $this->maybe( $coupon->get_minimum_amount(), static::IS_NULL ) ), + $this->expectedField( 'coupon.maximumAmount', $this->maybe( $coupon->get_maximum_amount(), static::IS_NULL ) ), + $this->expectedField( 'coupon.emailRestrictions', $this->maybe( $coupon->get_email_restrictions(), static::IS_NULL ) ), ]; foreach ( $coupon->get_product_ids() as $product_id ) { @@ -124,7 +124,7 @@ public function testCouponQuery() { $this->loginAsCustomer(); $variables = [ 'id' => $this->toRelayId( 'shop_coupon', $coupon_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'coupon', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'coupon', static::IS_NULL ) ]; $this->assertQuerySuccessful( $response, $expected ); @@ -230,7 +230,7 @@ public function testCouponsQueryAndWhereArgs() { $this->loginAsCustomer(); $response = $this->graphql( compact( 'query' ) ); $expected = [ - $this->expectedField( 'coupons.nodes', self::IS_FALSY ), + $this->expectedField( 'coupons.nodes', static::IS_FALSY ), ]; $this->assertQuerySuccessful( $response, $expected ); diff --git a/tests/wpunit/CustomerQueriesTest.php b/tests/wpunit/CustomerQueriesTest.php index 5ea00562..4e7fa34a 100644 --- a/tests/wpunit/CustomerQueriesTest.php +++ b/tests/wpunit/CustomerQueriesTest.php @@ -18,7 +18,7 @@ public function expectedCustomerData( $id ) { $this->expectedObject( 'customer', [ - $this->expectedField( 'id', $this->toRelayId( 'customer', $id ) ), + $this->expectedField( 'id', $this->toRelayId( 'user', $id ) ), $this->expectedField( 'databaseId', $id ), $this->expectedField( 'isVatExempt', $customer->get_is_vat_exempt() ), $this->expectedField( 'hasCalculatedShipping', $customer->has_calculated_shipping() ), @@ -37,7 +37,7 @@ public function expectedCustomerData( $id ) { 'lastOrder.databaseId', $customer->get_last_order() ? $customer->get_last_order()->get_id() - : self::IS_NULL + : static::IS_NULL ), $this->expectedObject( 'billing', @@ -70,13 +70,13 @@ public function expectedCustomerData( $id ) { 'jwtAuthToken', ! is_wp_error( \WPGraphQL\JWT_Authentication\Auth::get_token( $wp_user ) ) ? \WPGraphQL\JWT_Authentication\Auth::get_token( $wp_user ) - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'jwtRefreshToken', ! is_wp_error( \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $wp_user ) ) ? \WPGraphQL\JWT_Authentication\Auth::get_refresh_token( $wp_user ) - : self::IS_NULL + : static::IS_NULL ), ] ), @@ -142,11 +142,11 @@ public function testCustomerQueryAndArgs() { * Query should return null value due to lack of permissions. */ $this->loginAsCustomer(); - $variables = [ 'id' => $this->toRelayId( 'customer', $new_customer_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'user', $new_customer_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'customer' ), - $this->expectedField( 'customer', self::IS_NULL ), + $this->expectedField( 'customer', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -159,7 +159,7 @@ public function testCustomerQueryAndArgs() { * * Query should return requested data because user queried themselves. */ - $variables = [ 'id' => $this->toRelayId( 'customer', $this->customer ) ]; + $variables = [ 'id' => $this->toRelayId( 'user', $this->customer ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = $this->expectedCustomerData( $this->customer ); @@ -175,14 +175,14 @@ public function testCustomerQueryAndArgs() { * but should not have access to JWT fields. */ $this->loginAsShopManager(); - $variables = [ 'id' => $this->toRelayId( 'customer', $new_customer_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'user', $new_customer_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = array_merge( [ $this->expectedErrorPath( 'customer.jwtAuthToken' ), - $this->expectedField( 'customer.jwtAuthToken', self::IS_NULL ), + $this->expectedField( 'customer.jwtAuthToken', static::IS_NULL ), $this->expectedErrorPath( 'customer.jwtRefreshToken' ), - $this->expectedField( 'customer.jwtRefreshToken', self::IS_NULL ), + $this->expectedField( 'customer.jwtRefreshToken', static::IS_NULL ), ], $this->expectedCustomerData( $new_customer_id ) ); @@ -230,7 +230,7 @@ public function testCustomerQueryAndArgs() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'customer' ), - $this->expectedField( 'customer', self::IS_NULL ), + $this->expectedField( 'customer', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -300,10 +300,10 @@ public function testCustomersQueryAndWhereArgs() { $this->expectedField( 'customers.nodes.#.databaseId', $users[1] ), $this->expectedField( 'customers.nodes.#.databaseId', $users[2] ), $this->expectedField( 'customers.nodes.#.databaseId', $users[3] ), - $this->expectedField( 'customers.nodes.0.billing.email', self::NOT_NULL ), - $this->expectedField( 'customers.nodes.1.billing.email', self::NOT_NULL ), - $this->expectedField( 'customers.nodes.2.billing.email', self::NOT_NULL ), - $this->expectedField( 'customers.nodes.3.billing.email', self::NOT_NULL ), + $this->expectedField( 'customers.nodes.0.billing.email', static::NOT_NULL ), + $this->expectedField( 'customers.nodes.1.billing.email', static::NOT_NULL ), + $this->expectedField( 'customers.nodes.2.billing.email', static::NOT_NULL ), + $this->expectedField( 'customers.nodes.3.billing.email', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -317,7 +317,7 @@ public function testCustomersQueryAndWhereArgs() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedField( 'customers.nodes.0.databaseId', $users[0] ), - $this->expectedField( 'customers.nodes.0.billing.email', self::NOT_NULL ), + $this->expectedField( 'customers.nodes.0.billing.email', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -331,7 +331,7 @@ public function testCustomersQueryAndWhereArgs() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedField( 'customers.nodes.0.databaseId', $users[2] ), - $this->expectedField( 'customers.nodes.0.billing.email', self::NOT_NULL ), + $this->expectedField( 'customers.nodes.0.billing.email', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -347,9 +347,9 @@ public function testCustomersQueryAndWhereArgs() { $this->expectedField( 'customers.nodes.#.databaseId', $users[0] ), $this->expectedField( 'customers.nodes.#.databaseId', $users[1] ), $this->expectedField( 'customers.nodes.#.databaseId', $users[3] ), - $this->expectedField( 'customers.nodes.0.billing.email', self::NOT_NULL ), - $this->expectedField( 'customers.nodes.1.billing.email', self::NOT_NULL ), - $this->expectedField( 'customers.nodes.2.billing.email', self::NOT_NULL ), + $this->expectedField( 'customers.nodes.0.billing.email', static::NOT_NULL ), + $this->expectedField( 'customers.nodes.1.billing.email', static::NOT_NULL ), + $this->expectedField( 'customers.nodes.2.billing.email', static::NOT_NULL ), $this->not()->expectedField( 'customers.nodes.#.databaseId', $users[2] ), ]; @@ -528,9 +528,9 @@ public function testCustomerAvailablePaymentMethodsField() { /** * Assert tokens are inaccessible as guest or admin */ - $variables = [ 'id' => $this->toRelayId( 'customer', $customer_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'user', $customer_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'customer', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'customer', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); @@ -538,8 +538,8 @@ public function testCustomerAvailablePaymentMethodsField() { $this->loginAsShopManager(); $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), - $this->expectedField( 'customer.availablePaymentMethods', self::IS_NULL ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), + $this->expectedField( 'customer.availablePaymentMethods', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -550,7 +550,7 @@ public function testCustomerAvailablePaymentMethodsField() { $this->loginAs( $customer_id ); $response = $this->graphql( compact( 'query' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), $this->expectedNode( 'customer.availablePaymentMethods', [ @@ -645,16 +645,16 @@ static function ( $session_class ) { * Assert NULL values when querying as admin */ $this->loginAsShopManager(); - $variables = [ 'id' => $this->toRelayId( 'customer', $customer_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'user', $customer_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), - $this->expectedField( 'customer.cartUrl', self::IS_NULL ), - $this->expectedField( 'customer.cartNonce', self::IS_NULL ), - $this->expectedField( 'customer.checkoutUrl', self::IS_NULL ), - $this->expectedField( 'customer.checkoutNonce', self::IS_NULL ), - $this->expectedField( 'customer.addPaymentMethodUrl', self::IS_NULL ), - $this->expectedField( 'customer.addPaymentMethodNonce', self::IS_NULL ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), + $this->expectedField( 'customer.cartUrl', static::IS_NULL ), + $this->expectedField( 'customer.cartNonce', static::IS_NULL ), + $this->expectedField( 'customer.checkoutUrl', static::IS_NULL ), + $this->expectedField( 'customer.checkoutNonce', static::IS_NULL ), + $this->expectedField( 'customer.addPaymentMethodUrl', static::IS_NULL ), + $this->expectedField( 'customer.addPaymentMethodNonce', static::IS_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -664,13 +664,13 @@ static function ( $session_class ) { $this->loginAs( $customer_id ); $response = $this->graphql( compact( 'query' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), - $this->expectedField( 'customer.cartUrl', self::NOT_NULL ), - $this->expectedField( 'customer.cartNonce', self::NOT_NULL ), - $this->expectedField( 'customer.checkoutUrl', self::NOT_NULL ), - $this->expectedField( 'customer.checkoutNonce', self::NOT_NULL ), - $this->expectedField( 'customer.addPaymentMethodUrl', self::NOT_NULL ), - $this->expectedField( 'customer.addPaymentMethodNonce', self::NOT_NULL ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), + $this->expectedField( 'customer.cartUrl', static::NOT_NULL ), + $this->expectedField( 'customer.cartNonce', static::NOT_NULL ), + $this->expectedField( 'customer.checkoutUrl', static::NOT_NULL ), + $this->expectedField( 'customer.checkoutNonce', static::NOT_NULL ), + $this->expectedField( 'customer.addPaymentMethodUrl', static::NOT_NULL ), + $this->expectedField( 'customer.addPaymentMethodNonce', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); } diff --git a/tests/wpunit/DownloadableItemQueriesTest.php b/tests/wpunit/DownloadableItemQueriesTest.php index 4053d62e..76bd11b1 100644 --- a/tests/wpunit/DownloadableItemQueriesTest.php +++ b/tests/wpunit/DownloadableItemQueriesTest.php @@ -85,7 +85,7 @@ function ( $item ) { 'downloadsRemaining', isset( $item['downloads_remaining'] ) && 'integer' === gettype( $item['downloads_remaining'] ) ? $item['downloads_remaining'] - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'name', $item['download_name'] ), $this->expectedField( 'product.databaseId', $item['product_id'] ), @@ -355,14 +355,14 @@ function ( $item ) { $this->expectedField( 'url', $item['download_url'] ), $this->expectedField( 'accessExpires', - ! empty( $item['access_expires'] ) ? $item['access_expires'] : self::IS_NULL + ! empty( $item['access_expires'] ) ? $item['access_expires'] : static::IS_NULL ), $this->expectedField( 'downloadId', $item['download_id'] ), $this->expectedField( 'downloadsRemaining', isset( $item['downloads_remaining'] ) && 'integer' === gettype( $item['downloads_remaining'] ) ? $item['downloads_remaining'] - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'name', $item['download_name'] ), $this->expectedField( 'product.databaseId', $item['product_id'] ), diff --git a/tests/wpunit/MetaDataQueriesTest.php b/tests/wpunit/MetaDataQueriesTest.php index 431157ad..ba0682c8 100644 --- a/tests/wpunit/MetaDataQueriesTest.php +++ b/tests/wpunit/MetaDataQueriesTest.php @@ -405,7 +405,7 @@ public function testCustomerMetaDataQueries() { $this->loginAs( $customer_id ); $response = $this->graphql( compact( 'query' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), $this->expectedObject( 'customer.metaData.#', [ @@ -541,10 +541,10 @@ public function testProductMetaDataQueries() { /** * Assertion One */ - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedObject( 'product.metaData.#', [ @@ -596,10 +596,10 @@ public function testProductVariationMetaDataQueries() { /** * Assertion One */ - $variables = [ 'id' => $this->toRelayId( 'product_variation', $variation_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $variation_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'productVariation.id', $this->toRelayId( 'product_variation', $variation_id ) ), + $this->expectedField( 'productVariation.id', $this->toRelayId( 'post', $variation_id ) ), $this->expectedObject( 'productVariation.metaData.#', [ diff --git a/tests/wpunit/OrderItemQueriesTest.php b/tests/wpunit/OrderItemQueriesTest.php index e9027608..978f6c4c 100644 --- a/tests/wpunit/OrderItemQueriesTest.php +++ b/tests/wpunit/OrderItemQueriesTest.php @@ -46,8 +46,8 @@ function ( $item ) { $this->expectedField( 'databaseId', $item->get_id() ), $this->expectedField( 'orderId', $item->get_order_id() ), $this->expectedField( 'code', $item->get_code() ), - $this->expectedField( 'discount', $this->maybe( $item->get_discount(), self::IS_NULL ) ), - $this->expectedField( 'discountTax', $this->maybe( $item->get_discount_tax(), self::IS_NULL ) ), + $this->expectedField( 'discount', $this->maybe( $item->get_discount(), static::IS_NULL ) ), + $this->expectedField( 'discountTax', $this->maybe( $item->get_discount_tax(), static::IS_NULL ) ), $this->expectedField( 'coupon.id', $this->toRelayId( 'shop_coupon', \wc_get_coupon_id_by_code( $item->get_code() ) ) ), ] ); @@ -103,7 +103,7 @@ function ( $item ) { $this->expectedField( 'name', $item->get_name() ), $this->expectedField( 'taxStatus', strtoupper( $item->get_tax_status() ) ), $this->expectedField( 'total', $item->get_total() ), - $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), self::IS_NULL ) ), + $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), static::IS_NULL ) ), $this->expectedField( 'taxClass', ! empty( $item->get_tax_class() ) @@ -159,7 +159,7 @@ function ( $item ) { $this->expectedField( 'orderId', $item->get_order_id() ), $this->expectedField( 'methodTitle', $item->get_method_title() ), $this->expectedField( 'total', $item->get_total() ), - $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), self::IS_NULL ) ), + $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), static::IS_NULL ) ), $this->expectedField( 'taxClass', ! empty( $item->get_tax_class() ) @@ -287,7 +287,7 @@ function ( $item ) { 'order.lineItems.nodes', [ $this->expectedField( 'productId', $item->get_product_id() ), - $this->expectedField( 'variationId', $this->maybe( $item->get_variation_id(), self::IS_NULL ) ), + $this->expectedField( 'variationId', $this->maybe( $item->get_variation_id(), static::IS_NULL ) ), $this->expectedField( 'quantity', $item->get_quantity() ), $this->expectedField( 'taxClass', @@ -295,18 +295,18 @@ function ( $item ) { ? strtoupper( $item->get_tax_class() ) : 'STANDARD' ), - $this->expectedField( 'subtotal', $this->maybe( $item->get_subtotal(), self::IS_NULL ) ), - $this->expectedField( 'subtotalTax', $this->maybe( $item->get_subtotal_tax(), self::IS_NULL ) ), - $this->expectedField( 'total', $this->maybe( $item->get_total(), self::IS_NULL ) ), - $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), self::IS_NULL ) ), + $this->expectedField( 'subtotal', $this->maybe( $item->get_subtotal(), static::IS_NULL ) ), + $this->expectedField( 'subtotalTax', $this->maybe( $item->get_subtotal_tax(), static::IS_NULL ) ), + $this->expectedField( 'total', $this->maybe( $item->get_total(), static::IS_NULL ) ), + $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), static::IS_NULL ) ), $this->expectedField( 'itemDownloads', null ), $this->expectedField( 'taxStatus', strtoupper( $item->get_tax_status() ) ), - $this->expectedField( 'product.node.id', $this->toRelayId( 'product', $item->get_product_id() ) ), + $this->expectedField( 'product.node.id', $this->toRelayId( 'post', $item->get_product_id() ) ), $this->expectedField( 'variation.node.id', ! empty( $item->get_variation_id() ) - ? $this->toRelayId( 'product_variation', $item->get_variation_id() ) - : self::IS_NULL + ? $this->toRelayId( 'post', $item->get_variation_id() ) + : static::IS_NULL ), ] ); diff --git a/tests/wpunit/OrderQueriesTest.php b/tests/wpunit/OrderQueriesTest.php index 940d2fab..62fafcbc 100644 --- a/tests/wpunit/OrderQueriesTest.php +++ b/tests/wpunit/OrderQueriesTest.php @@ -29,15 +29,15 @@ public function expectedOrderData( $order_id ) { $this->expectedField( 'orderKey', $order->get_order_key() ), $this->expectedField( 'createdVia', $this->maybe( $order->get_created_via() ) ), $this->expectedField( 'pricesIncludeTax', $order->get_prices_include_tax() ), - $this->expectedField( 'parent', self::IS_NULL ), + $this->expectedField( 'parent', static::IS_NULL ), $this->expectedField( 'customer', $this->maybe( [ $order->get_customer_id(), - [ 'id' => $this->toRelayId( 'customer', $order->get_customer_id() ) ], + [ 'id' => $this->toRelayId( 'user', $order->get_customer_id() ) ], ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'customerIpAddress', $this->maybe( $order->get_customer_ip_address() ) ), @@ -193,7 +193,7 @@ public function testOrderQuery() { $this->loginAsCustomer(); $variables = [ 'id' => $id ]; $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'order', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'order', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); diff --git a/tests/wpunit/PaymentGatewayQueriesTest.php b/tests/wpunit/PaymentGatewayQueriesTest.php index 7ff0820e..73607214 100644 --- a/tests/wpunit/PaymentGatewayQueriesTest.php +++ b/tests/wpunit/PaymentGatewayQueriesTest.php @@ -88,7 +88,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { [ $this->expectedField( 'id', 'bacs' ), $this->expectedField( 'title', 'Direct bank transfer' ), - $this->expectedField( 'icon', self::IS_NULL ), + $this->expectedField( 'icon', static::IS_NULL ), ] ), ]; @@ -104,7 +104,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ $this->expectedErrorPath( 'paymentGateways' ), - $this->expectedField( 'paymentGateways', self::IS_NULL ), + $this->expectedField( 'paymentGateways', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -124,7 +124,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { [ $this->expectedField( 'id', 'bacs' ), $this->expectedField( 'title', 'Direct bank transfer' ), - $this->expectedField( 'icon', self::IS_NULL ), + $this->expectedField( 'icon', static::IS_NULL ), ] ), $this->expectedNode( @@ -132,7 +132,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { [ $this->expectedField( 'id', 'cheque' ), $this->expectedField( 'title', 'Check payments' ), - $this->expectedField( 'icon', self::IS_NULL ), + $this->expectedField( 'icon', static::IS_NULL ), ] ), $this->expectedNode( @@ -140,7 +140,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { [ $this->expectedField( 'id', 'cod' ), $this->expectedField( 'title', 'Cash on delivery' ), - $this->expectedField( 'icon', self::IS_NULL ), + $this->expectedField( 'icon', static::IS_NULL ), ] ), $this->expectedNode( @@ -148,7 +148,7 @@ public function testPaymentGatewaysQueryAndWhereArgs() { [ $this->expectedField( 'id', 'stripe' ), $this->expectedField( 'title', 'Credit Card (Stripe)' ), - $this->expectedField( 'icon', self::IS_NULL ), + $this->expectedField( 'icon', static::IS_NULL ), ] ), ]; diff --git a/tests/wpunit/PaymentMethodMutationsTest.php b/tests/wpunit/PaymentMethodMutationsTest.php index 3916bbf1..8c591de8 100644 --- a/tests/wpunit/PaymentMethodMutationsTest.php +++ b/tests/wpunit/PaymentMethodMutationsTest.php @@ -46,14 +46,14 @@ public function testSetDefaultPaymentMethodMutation() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'setDefaultPaymentMethod', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'setDefaultPaymentMethod', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); // Again, as admin. $this->loginAsShopManager(); $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'setDefaultPaymentMethod', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'setDefaultPaymentMethod', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); @@ -132,14 +132,14 @@ public function testDeletePaymentMethodMutation() { */ $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'deletePaymentMethod', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'deletePaymentMethod', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); // Again, as admin. $this->loginAsShopManager(); $response = $this->graphql( compact( 'query', 'variables' ) ); - $expected = [ $this->expectedField( 'deletePaymentMethod', self::IS_NULL ) ]; + $expected = [ $this->expectedField( 'deletePaymentMethod', static::IS_NULL ) ]; $this->assertQueryError( $response, $expected ); diff --git a/tests/wpunit/ProductAttributeQueriesTest.php b/tests/wpunit/ProductAttributeQueriesTest.php index 6684c957..bd53478f 100644 --- a/tests/wpunit/ProductAttributeQueriesTest.php +++ b/tests/wpunit/ProductAttributeQueriesTest.php @@ -58,10 +58,10 @@ public function testProductAttributeQuery() { } '; - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = array_merge( - [ $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ) ], + [ $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ) ], $this->expectedProductAttributeData( $product_id, 'product.attributes.nodes' ) ); @@ -123,7 +123,7 @@ public function testProductAttributeToProductConnectionQuery() { $variables = [ 'pattern' => 'polka-dot' ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'allPaPattern.nodes.0.products.nodes.0.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'allPaPattern.nodes.0.products.nodes.0.id', $this->toRelayId( 'post', $product_id ) ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -151,7 +151,7 @@ public function testProductAttributeToVariationConnectionQuery() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = array_map( function ( $id ) { - return $this->expectedField( 'allPaSize.nodes.0.variations.nodes.#.id', $this->toRelayId( 'product_variation', $id ) ); + return $this->expectedField( 'allPaSize.nodes.0.variations.nodes.#.id', $this->toRelayId( 'post', $id ) ); }, array_filter( $variation_ids, diff --git a/tests/wpunit/ProductQueriesTest.php b/tests/wpunit/ProductQueriesTest.php index b66452e7..1c166537 100644 --- a/tests/wpunit/ProductQueriesTest.php +++ b/tests/wpunit/ProductQueriesTest.php @@ -9,7 +9,7 @@ public function getExpectedProductData( $product_id ) { } return [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedField( 'product.databaseId', $product->get_id() ), $this->expectedField( 'product.name', $product->get_name() ), $this->expectedField( 'product.slug', $product->get_slug() ), @@ -20,7 +20,7 @@ public function getExpectedProductData( $product_id ) { 'product.description', $this->maybe( [ $product->get_description(), apply_filters( 'the_content', $product->get_description() ) ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( @@ -33,7 +33,7 @@ public function getExpectedProductData( $product_id ) { apply_filters( 'the_excerpt', $product->get_short_description() ) ), ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.sku', $product->get_sku() ), @@ -41,34 +41,34 @@ public function getExpectedProductData( $product_id ) { 'product.price', $this->maybe( [ $product->get_price(), \wc_graphql_price( $product->get_price() ) ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.regularPrice', $this->maybe( [ $product->get_regular_price(), \wc_graphql_price( $product->get_regular_price() ) ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.salePrice', $this->maybe( [ $product->get_sale_price(), \wc_graphql_price( $product->get_sale_price() ) ], - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.dateOnSaleFrom', - $this->maybe( $product->get_date_on_sale_from(), self::IS_NULL ) + $this->maybe( $product->get_date_on_sale_from(), static::IS_NULL ) ), $this->expectedField( 'product.dateOnSaleTo', - $this->maybe( $product->get_date_on_sale_to(), self::IS_NULL ) + $this->maybe( $product->get_date_on_sale_to(), static::IS_NULL ) ), $this->expectedField( 'product.taxStatus', - $this->maybe( strtoupper( $product->get_tax_status() ), self::IS_NULL ) + $this->maybe( strtoupper( $product->get_tax_status() ), static::IS_NULL ) ), $this->expectedField( 'product.taxClass', @@ -78,67 +78,67 @@ public function getExpectedProductData( $product_id ) { 'product.manageStock', ! empty( $product->get_manage_stock() ) ? \WPGraphQL\Type\WPEnumType::get_safe_name( $product->get_manage_stock() ) - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'product.stockQuantity', - $this->maybe( $product->get_stock_quantity(), self::IS_NULL ) + $this->maybe( $product->get_stock_quantity(), static::IS_NULL ) ), $this->expectedField( 'product.stockStatus', $this->maybe( $this->factory->product->getStockStatusEnum( $product->get_stock_status() ), - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.backorders', $this->maybe( \WPGraphQL\Type\WPEnumType::get_safe_name( $product->get_backorders() ), - self::IS_NULL + static::IS_NULL ) ), $this->expectedField( 'product.soldIndividually', $product->get_sold_individually() ), $this->expectedField( 'product.weight', - $this->maybe( $product->get_weight(), self::IS_NULL ) + $this->maybe( $product->get_weight(), static::IS_NULL ) ), $this->expectedField( 'product.length', - $this->maybe( $product->get_length(), self::IS_NULL ) + $this->maybe( $product->get_length(), static::IS_NULL ) ), $this->expectedField( 'product.width', - $this->maybe( $product->get_width(), self::IS_NULL ) + $this->maybe( $product->get_width(), static::IS_NULL ) ), $this->expectedField( 'product.height', - $this->maybe( $product->get_height(), self::IS_NULL ) + $this->maybe( $product->get_height(), static::IS_NULL ) ), $this->expectedField( 'product.reviewsAllowed', - $this->maybe( $product->get_reviews_allowed(), self::IS_NULL ) + $this->maybe( $product->get_reviews_allowed(), static::IS_NULL ) ), $this->expectedField( 'product.purchaseNote', - $this->maybe( $product->get_purchase_note(), self::IS_NULL ) + $this->maybe( $product->get_purchase_note(), static::IS_NULL ) ), $this->expectedField( 'product.menuOrder', $product->get_menu_order() ), $this->expectedField( 'product.virtual', $product->get_virtual() ), - $this->expectedField( 'product.downloadable', $product->get_downloadable(), self::IS_NULL ), + $this->expectedField( 'product.downloadable', $product->get_downloadable(), static::IS_NULL ), $this->expectedField( 'product.downloadLimit', - $this->maybe( $product->get_download_limit(), self::IS_NULL ) + $this->maybe( $product->get_download_limit(), static::IS_NULL ) ), $this->expectedField( 'product.downloadExpiry', - $this->maybe( $product->get_download_expiry(), self::IS_NULL ) + $this->maybe( $product->get_download_expiry(), static::IS_NULL ) ), $this->expectedField( 'product.averageRating', (float) $product->get_average_rating() ), $this->expectedField( 'product.reviewCount', (int) $product->get_review_count() ), $this->expectedField( 'product.backordersAllowed', - $this->maybe( $product->backorders_allowed(), self::IS_FALSY ) + $this->maybe( $product->backorders_allowed(), static::IS_FALSY ) ), $this->expectedField( 'product.onSale', $product->is_on_sale() ), $this->expectedField( 'product.purchasable', $product->is_purchasable() ), @@ -146,7 +146,7 @@ public function getExpectedProductData( $product_id ) { $this->expectedField( 'product.shippingTaxable', $product->is_shipping_taxable() ), $this->expectedField( 'product.link', - $this->maybe( get_post_permalink( $product_id ), self::IS_NULL ) + $this->maybe( get_post_permalink( $product_id ), static::IS_NULL ) ), $this->expectedField( 'product.totalSales', @@ -155,7 +155,7 @@ public function getExpectedProductData( $product_id ) { $is_shop_manager && $product->get_total_sales(), $product->get_total_sales(), ], - self::IS_FALSY + static::IS_FALSY ) ), $this->expectedField( @@ -165,7 +165,7 @@ public function getExpectedProductData( $product_id ) { $is_shop_manager && ! empty( $product->get_catalog_visibility() ), strtoupper( $product->get_catalog_visibility() ), ], - self::IS_NULL + static::IS_NULL ) ), ]; @@ -258,7 +258,7 @@ public function testSimpleProductQuery() { * * Test querying product. */ - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = $this->getExpectedProductData( $product_id ); @@ -274,7 +274,7 @@ public function testSimpleProductQuery() { */ $this->loginAsShopManager(); $variables = [ - 'id' => $this->toRelayId( 'product', $product_id ), + 'id' => $this->toRelayId( 'post', $product_id ), 'format' => 'RAW', ]; $response = $this->graphql( compact( 'query', 'variables' ) ); @@ -351,7 +351,7 @@ public function testProductTaxonomies() { ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedField( 'product.image.id', $this->toRelayId( 'post', $attachment_id ) ), $this->expectedNode( 'product.productCategories.nodes', @@ -387,7 +387,7 @@ public function testProductQueryAndIds() { // Define expected data for coming assertions. $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), ]; /** @@ -408,7 +408,7 @@ public function testProductQueryAndIds() { * Test querying product with "ID" set as the "idType". */ $variables = [ - 'id' => $this->toRelayId( 'product', $product_id ), + 'id' => $this->toRelayId( 'post', $product_id ), 'idType' => 'ID', ]; $response = $this->graphql( compact( 'query', 'variables' ) ); @@ -448,7 +448,7 @@ public function testProductToTermConnection() { 'category_ids' => [ $test_category ], ] ); - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $query = ' query ($id: ID!) { @@ -573,8 +573,8 @@ public function testTermToProductConnection() { 'productTags.nodes', [ $this->expectedField( 'name', 'test-product-tag-2' ), - $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'product', $product_id ) ), - $this->expectedField( 'products.nodes.1.id', $this->toRelayId( 'product', $expensive_product_id ) ), + $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'post', $product_id ) ), + $this->expectedField( 'products.nodes.1.id', $this->toRelayId( 'post', $expensive_product_id ) ), ], 0 ), @@ -583,8 +583,8 @@ public function testTermToProductConnection() { [ $this->expectedField( 'name', 'test-product-category-2' ), $this->expectedField( 'image.id', $this->toRelayId( 'post', $image_id ) ), - $this->expectedField( 'products.nodes.1.id', $this->toRelayId( 'product', $product_id ) ), - $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'product', $expensive_product_id ) ), + $this->expectedField( 'products.nodes.1.id', $this->toRelayId( 'post', $product_id ) ), + $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'post', $expensive_product_id ) ), ], 0 ), @@ -609,7 +609,7 @@ public function testProductToMediaItemConnections() { ] ); - $product_relay_id = $this->toRelayId( 'product', $product_id ); + $product_relay_id = $this->toRelayId( 'post', $product_id ); $image_relay_id = $this->toRelayId( 'post', $image_id ); $query = ' @@ -649,7 +649,7 @@ public function testProductDownloads() { ] ); - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $query = ' query ( $id: ID! ) { @@ -688,7 +688,7 @@ public function testExternalProductQuery() { 'button_text' => 'Buy a external product', ] ); - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $query = ' query ( $id: ID! ) { @@ -732,7 +732,7 @@ public function testGroupProductConnections() { [ 'children' => $grouped_product_ids ] ); - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $query = ' query ( $id: ID! ) { @@ -764,7 +764,7 @@ public function testGroupProductConnections() { foreach ( $product->get_children() as $grouped_product_id ) { $expected[] = $this->expectedNode( 'product.products.nodes', - [ 'id' => $this->toRelayId( 'product', $grouped_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $grouped_product_id ) ] ); } @@ -819,25 +819,25 @@ public function testRelatedProductConnections() { } '; - $variables = [ 'id' => $this->toRelayId( 'product', $products['product'] ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $products['product'] ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = []; foreach ( $products['related'] + $products['cross_sell'] + $products['upsell'] as $product_id ) { $expected[] = $this->expectedNode( 'product.related.nodes', - [ 'id' => $this->toRelayId( 'product', $product_id ) ] + [ 'id' => $this->toRelayId( 'post', $product_id ) ] ); } foreach ( $products['cross_sell'] as $product_id ) { $expected[] = $this->expectedNode( 'product.crossSell.nodes', - [ 'id' => $this->toRelayId( 'product', $product_id ) ] + [ 'id' => $this->toRelayId( 'post', $product_id ) ] ); } foreach ( $products['upsell'] as $product_id ) { $expected[] = $this->expectedNode( 'product.upsell.nodes', - [ 'id' => $this->toRelayId( 'product', $product_id ) ] + [ 'id' => $this->toRelayId( 'post', $product_id ) ] ); } @@ -853,7 +853,7 @@ public function testProductToReviewConnections() { $this->factory->product->createReview( $product_id ), $this->factory->product->createReview( $product_id ), ]; - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $product = \wc_get_product( $product_id ); $query = ' @@ -916,7 +916,7 @@ public function testProductGalleryImagesConnection() { } '; - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $this->assertQuerySuccessful( $response, @@ -999,7 +999,7 @@ public function testProductQueryWithInterfaces() { * * Test querying product. */ - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = $this->getExpectedProductData( $product_id ); @@ -1015,7 +1015,7 @@ public function testProductQueryWithInterfaces() { */ $this->loginAsShopManager(); $variables = [ - 'id' => $this->toRelayId( 'product', $product_id ), + 'id' => $this->toRelayId( 'post', $product_id ), 'format' => 'RAW', ]; $response = $this->graphql( compact( 'query', 'variables' ) ); @@ -1102,7 +1102,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $normal_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $normal_product_id ) ] ), ]; @@ -1124,7 +1124,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $special_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $special_product_id ) ] ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -1145,7 +1145,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $both_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $both_product_id ) ] ), ]; @@ -1168,7 +1168,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedField( 'products.nodes', - self::IS_FALSY + static::IS_FALSY ), ]; @@ -1191,7 +1191,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $special_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $special_product_id ) ] ), ]; @@ -1218,7 +1218,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $both_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $both_product_id ) ] ), ]; diff --git a/tests/wpunit/ProductVariationQueriesTest.php b/tests/wpunit/ProductVariationQueriesTest.php index ddb0fb91..a3e70e8f 100644 --- a/tests/wpunit/ProductVariationQueriesTest.php +++ b/tests/wpunit/ProductVariationQueriesTest.php @@ -7,7 +7,7 @@ public function expectedProductVariationData( $id ) { $data = new WC_Product_Variation( $id ); return [ - $this->expectedField( 'productVariation.id', $this->toRelayId( 'product_variation', $id ) ), + $this->expectedField( 'productVariation.id', $this->toRelayId( 'post', $id ) ), $this->expectedField( 'productVariation.databaseId', $data->get_id() ), $this->expectedField( 'productVariation.name', $data->get_name() ), $this->expectedField( 'productVariation.date', $data->get_date_created()->__toString() ), @@ -15,32 +15,32 @@ public function expectedProductVariationData( $id ) { 'productVariation.modified', ! empty( $data->get_date_created() ) ? $data->get_date_created()->__toString() - : self::IS_NULL + : static::IS_NULL ), - $this->expectedField( 'productVariation.description', ! empty( $data->get_description() ) ? $data->get_description() : self::IS_NULL ), + $this->expectedField( 'productVariation.description', ! empty( $data->get_description() ) ? $data->get_description() : static::IS_NULL ), $this->expectedField( 'productVariation.sku', $data->get_sku() ), - $this->expectedField( 'productVariation.price', ! empty( $data->get_price() ) ? \wc_graphql_price( $data->get_price() ) : self::IS_NULL ), - $this->expectedField( 'productVariation.regularPrice', ! empty( $data->get_regular_price() ) ? \wc_graphql_price( $data->get_regular_price() ) : self::IS_NULL ), - $this->expectedField( 'productVariation.salePrice', ! empty( $data->get_sale_price() ) ? \wc_graphql_price( $data->get_sale_price() ) : self::IS_NULL ), + $this->expectedField( 'productVariation.price', ! empty( $data->get_price() ) ? \wc_graphql_price( $data->get_price() ) : static::IS_NULL ), + $this->expectedField( 'productVariation.regularPrice', ! empty( $data->get_regular_price() ) ? \wc_graphql_price( $data->get_regular_price() ) : static::IS_NULL ), + $this->expectedField( 'productVariation.salePrice', ! empty( $data->get_sale_price() ) ? \wc_graphql_price( $data->get_sale_price() ) : static::IS_NULL ), $this->expectedField( 'productVariation.dateOnSaleFrom', ! empty( $data->get_date_on_sale_from() ) ? $data->get_date_on_sale_from() - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'productVariation.dateOnSaleTo', ! empty( $data->get_date_on_sale_to() ) ? $data->get_date_on_sale_to() - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'productVariation.onSale', $data->is_on_sale() ), $this->expectedField( 'productVariation.status', $data->get_status() ), - $this->expectedField( 'productVariation.purchasable', ! empty( $data->is_purchasable() ) ? $data->is_purchasable() : self::IS_NULL ), + $this->expectedField( 'productVariation.purchasable', ! empty( $data->is_purchasable() ) ? $data->is_purchasable() : static::IS_NULL ), $this->expectedField( 'productVariation.virtual', $data->is_virtual() ), $this->expectedField( 'productVariation.downloadable', $data->is_downloadable() ), - $this->expectedField( 'productVariation.downloadLimit', ! empty( $data->get_download_limit() ) ? $data->get_download_limit() : self::IS_NULL ), - $this->expectedField( 'productVariation.downloadExpiry', ! empty( $data->get_download_expiry() ) ? $data->get_download_expiry() : self::IS_NULL ), + $this->expectedField( 'productVariation.downloadLimit', ! empty( $data->get_download_limit() ) ? $data->get_download_limit() : static::IS_NULL ), + $this->expectedField( 'productVariation.downloadExpiry', ! empty( $data->get_download_expiry() ) ? $data->get_download_expiry() : static::IS_NULL ), $this->expectedField( 'productVariation.taxStatus', strtoupper( $data->get_tax_status() ) ), $this->expectedField( 'productVariation.taxClass', @@ -52,33 +52,33 @@ public function expectedProductVariationData( $id ) { 'productVariation.manageStock', ! empty( $data->get_manage_stock() ) ? WPEnumType::get_safe_name( $data->get_manage_stock() ) - : self::IS_NULL + : static::IS_NULL ), - $this->expectedField( 'productVariation.stockQuantity', ! empty( $data->get_stock_quantity() ) ? $data->get_stock_quantity() : self::IS_NULL ), + $this->expectedField( 'productVariation.stockQuantity', ! empty( $data->get_stock_quantity() ) ? $data->get_stock_quantity() : static::IS_NULL ), $this->expectedField( 'productVariation.stockStatus', ProductHelper::get_stock_status_enum( $data->get_stock_status() ) ), $this->expectedField( 'productVariation.backorders', ! empty( $data->get_backorders() ) ? WPEnumType::get_safe_name( $data->get_backorders() ) - : self::IS_NULL + : static::IS_NULL ), $this->expectedField( 'productVariation.backordersAllowed', $data->backorders_allowed() ), - $this->expectedField( 'productVariation.weight', ! empty( $data->get_weight() ) ? $data->get_weight() : self::IS_NULL ), - $this->expectedField( 'productVariation.length', ! empty( $data->get_length() ) ? $data->get_length() : self::IS_NULL ), - $this->expectedField( 'productVariation.width', ! empty( $data->get_width() ) ? $data->get_width() : self::IS_NULL ), - $this->expectedField( 'productVariation.height', ! empty( $data->get_height() ) ? $data->get_height() : self::IS_NULL ), + $this->expectedField( 'productVariation.weight', ! empty( $data->get_weight() ) ? $data->get_weight() : static::IS_NULL ), + $this->expectedField( 'productVariation.length', ! empty( $data->get_length() ) ? $data->get_length() : static::IS_NULL ), + $this->expectedField( 'productVariation.width', ! empty( $data->get_width() ) ? $data->get_width() : static::IS_NULL ), + $this->expectedField( 'productVariation.height', ! empty( $data->get_height() ) ? $data->get_height() : static::IS_NULL ), $this->expectedField( 'productVariation.menuOrder', $data->get_menu_order() ), - $this->expectedField( 'productVariation.purchaseNote', ! empty( $data->get_purchase_note() ) ? $data->get_purchase_note() : self::IS_NULL ), - $this->expectedField( 'productVariation.shippingClass', ! empty( $data->get_shipping_class() ) ? $data->get_shipping_class() : self::IS_NULL ), + $this->expectedField( 'productVariation.purchaseNote', ! empty( $data->get_purchase_note() ) ? $data->get_purchase_note() : static::IS_NULL ), + $this->expectedField( 'productVariation.shippingClass', ! empty( $data->get_shipping_class() ) ? $data->get_shipping_class() : static::IS_NULL ), $this->expectedField( 'productVariation.catalogVisibility', ! empty( $data->get_catalog_visibility() ) ? WPEnumType::get_safe_name( $data->get_catalog_visibility() ) - : self::IS_NULL + : static::IS_NULL ), - $this->expectedField( 'productVariation.hasAttributes', ! empty( $data->has_attributes() ) ? $data->has_attributes() : self::IS_NULL ), + $this->expectedField( 'productVariation.hasAttributes', ! empty( $data->has_attributes() ) ? $data->has_attributes() : static::IS_NULL ), $this->expectedField( 'productVariation.type', WPEnumType::get_safe_name( $data->get_type() ) ), - $this->expectedField( 'productVariation.parent.node.id', $this->toRelayId( 'product', $data->get_parent_id() ) ), + $this->expectedField( 'productVariation.parent.node.id', $this->toRelayId( 'post', $data->get_parent_id() ) ), ]; } @@ -89,7 +89,7 @@ public function testVariationQuery() { $this->factory->product->createVariable() ); $variation_id = $products['variations'][0]; - $id = $this->toRelayId( 'product_variation', $variation_id ); + $id = $this->toRelayId( 'post', $variation_id ); // Create query. $query = ' @@ -176,7 +176,7 @@ public function testProductVariationToMediaItemConnections() { $this->factory->product->createVariable() ); $variation_id = $products['variations'][1]; - $id = $this->toRelayId( 'product_variation', $variation_id ); + $id = $this->toRelayId( 'post', $variation_id ); $product = wc_get_product( $variation_id ); // Create query. @@ -207,7 +207,7 @@ public function testProductVariationDownloads() { $this->factory->product->createVariable() ); $variation_id = $products['variations'][0]; - $id = $this->toRelayId( 'product_variation', $variation_id ); + $id = $this->toRelayId( 'post', $variation_id ); $product = wc_get_product( $variation_id ); $downloads = (array) array_values( $product->get_downloads() ); @@ -297,9 +297,9 @@ public function testProductsQueriesWithVariations() { */ $response = $this->graphql( compact( 'query' ) ); $expected = [ - $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'product', $product_id ) ), - $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $variation_id ) ), - $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $other_variation_id ) ), + $this->expectedField( 'products.nodes.0.id', $this->toRelayId( 'post', $product_id ) ), + $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $variation_id ) ), + $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $other_variation_id ) ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -310,9 +310,9 @@ public function testProductsQueriesWithVariations() { $variables = [ 'type' => 'VARIATION' ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product', $product_id ) ), - $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $variation_id ) ), - $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $other_variation_id ) ), + $this->not()->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $product_id ) ), + $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $variation_id ) ), + $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $other_variation_id ) ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -323,9 +323,9 @@ public function testProductsQueriesWithVariations() { $variables = [ 'includeVariations' => true ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product', $product_id ) ), - $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $variation_id ) ), - $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'product_variation', $other_variation_id ) ), + $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $product_id ) ), + $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $variation_id ) ), + $this->expectedField( 'products.nodes.#.id', $this->toRelayId( 'post', $other_variation_id ) ), ]; $this->assertQuerySuccessful( $response, $expected ); diff --git a/tests/wpunit/ProductsQueriesTest.php b/tests/wpunit/ProductsQueriesTest.php index 5d1ec287..235e726f 100644 --- a/tests/wpunit/ProductsQueriesTest.php +++ b/tests/wpunit/ProductsQueriesTest.php @@ -292,7 +292,7 @@ public function testProductsQueryAndWhereArgs() { function ( $product_id ) { return $this->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_id ) ) ] + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_id ) ) ] ); }, $product_ids @@ -445,12 +445,12 @@ static function ( $node, $index ) use ( $product_ids ) { $expected = [ $this->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[0] ) ) ], + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[0] ) ) ], 0 ), $this->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[1] ) ) ], + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[1] ) ) ], 4 ), ]; @@ -598,7 +598,7 @@ static function ( $node, $index ) use ( $product_ids, $category_4, $category_3 ) $expected = [ $this->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[0] ) ) ] + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[0] ) ) ] ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -627,7 +627,7 @@ static function ( $node, $index ) use ( $product_ids, $category_4, $category_3 ) $expected = [ $this->not()->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[0] ) ) ] + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[0] ) ) ] ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -652,7 +652,7 @@ static function ( $node, $index ) use ( $product_ids, $category_4, $category_3 ) $expected = [ $this->not()->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[4] ) ) ] + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[4] ) ) ] ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -662,7 +662,7 @@ static function ( $node, $index ) use ( $product_ids, $category_4, $category_3 ) $expected = [ $this->expectedNode( 'products.nodes', - [ $this->expectedField( 'id', $this->toRelayId( 'product', $product_ids[4] ) ) ], + [ $this->expectedField( 'id', $this->toRelayId( 'post', $product_ids[4] ) ) ], 0 ), ]; @@ -675,7 +675,7 @@ public function testVariationsQueryAndWhereArgs() { $this->factory->product->createVariable() ); $variation_id = $products['variations'][0]; - $id = $this->toRelayId( 'product', $products['product'] ); + $id = $this->toRelayId( 'post', $products['product'] ); $product = wc_get_product( $products['product'] ); $variations = $products['variations']; $prices = $product->get_variation_prices( true ); @@ -718,9 +718,9 @@ public function testVariationsQueryAndWhereArgs() { $variables = [ 'id' => $id ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[0] ) ), - $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[1] ) ), - $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[2] ) ), + $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[0] ) ), + $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[1] ) ), + $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[2] ) ), $this->expectedField( 'product.price', \wc_graphql_price( current( $prices['price'] ) ) @@ -751,9 +751,9 @@ public function testVariationsQueryAndWhereArgs() { ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->not()->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[0] ) ), - $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[1] ) ), - $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'product_variation', $variations[2] ) ), + $this->not()->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[0] ) ), + $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[1] ) ), + $this->expectedField( 'product.variations.nodes.#.id', $this->toRelayId( 'post', $variations[2] ) ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -810,14 +810,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[0] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[0] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[1] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[1] ) ) ], 1 ), @@ -848,14 +848,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[2] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[2] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[3] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[3] ) ) ], 1 ), @@ -883,14 +883,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[0] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[0] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[1] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[1] ) ) ], 1 ), @@ -919,14 +919,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[2] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[2] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[3] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[3] ) ) ], 1 ), @@ -953,14 +953,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[0] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[0] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[1] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[1] ) ) ], 1 ), @@ -989,14 +989,14 @@ public function testProductsOrderbyArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[4] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[4] ) ) ], 0 ), $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[2] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[2] ) ) ], 1 ), @@ -1045,7 +1045,7 @@ public function testProductsSearchArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[1] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[1] ) ) ], 0 ), @@ -1066,7 +1066,7 @@ public function testProductsSearchArg() { $this->expectedNode( 'products.nodes', [ - $this->expectedField( 'id', $this->toRelayId( 'product', $products[1] ) ) + $this->expectedField( 'id', $this->toRelayId( 'post', $products[1] ) ) ], 0 ), diff --git a/tests/wpunit/RefundQueriesTest.php b/tests/wpunit/RefundQueriesTest.php index c7b9cd2e..cd173260 100644 --- a/tests/wpunit/RefundQueriesTest.php +++ b/tests/wpunit/RefundQueriesTest.php @@ -49,7 +49,7 @@ public function testRefundQuery() { $variables = [ 'id' => $relay_id ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'refund', self::IS_NULL ), + $this->expectedField( 'refund', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); diff --git a/tests/wpunit/ShippingMethodQueriesTest.php b/tests/wpunit/ShippingMethodQueriesTest.php index 786fc76d..6484ec0b 100644 --- a/tests/wpunit/ShippingMethodQueriesTest.php +++ b/tests/wpunit/ShippingMethodQueriesTest.php @@ -41,8 +41,8 @@ public function testShippingMethodQueryAndArgs() { $expected = [ $this->expectedField( 'shippingMethod.id', $id ), $this->expectedField( 'shippingMethod.databaseId', 'flat_rate' ), - $this->expectedField( 'shippingMethod.title', self::NOT_NULL ), - $this->expectedField( 'shippingMethod.description', self::NOT_NULL ), + $this->expectedField( 'shippingMethod.title', static::NOT_NULL ), + $this->expectedField( 'shippingMethod.description', static::NOT_NULL ), ]; $this->assertQuerySuccessful( $response, $expected ); @@ -75,7 +75,7 @@ public function testShippingMethodsQuery() { * Confirm permission check is working */ $response = $this->graphql( compact( 'query' ) ); - $this->assertQuerySuccessful( $response, [ $this->expectedField( 'shippingMethods.nodes', self::IS_FALSY ) ] ); + $this->assertQuerySuccessful( $response, [ $this->expectedField( 'shippingMethods.nodes', static::IS_FALSY ) ] ); // Login as shop manager. $this->loginAsShopManager(); diff --git a/tests/wpunit/ShippingZoneMutationsTest.php b/tests/wpunit/ShippingZoneMutationsTest.php index 6ff065da..79ced9f1 100644 --- a/tests/wpunit/ShippingZoneMutationsTest.php +++ b/tests/wpunit/ShippingZoneMutationsTest.php @@ -34,7 +34,7 @@ public function testCreateShippingZoneMutation() { $this->expectedObject( 'createShippingZone.shippingZone', [ - $this->expectedField( 'id', self::NOT_NULL ), + $this->expectedField( 'id', static::NOT_NULL ), $this->expectedField( 'name', 'Test Shipping Zone' ), $this->expectedField( 'order', 0 ), ] @@ -314,7 +314,7 @@ public function testClearShippingZoneLocationsMutation() { 'clearShippingZoneLocations.shippingZone', [ $this->expectedField( 'id', $this->toRelayId( 'shipping_zone', $shipping_zone->get_id() ) ), - $this->expectedField( 'locations', self::IS_FALSY ) + $this->expectedField( 'locations', static::IS_FALSY ) ] ), $this->expectedObject( @@ -422,8 +422,8 @@ public function testAddMethodToShippingZoneMutation() { $this->expectedNode( 'methods.edges', [ - $this->expectedField( 'id', self::NOT_NULL ), - $this->expectedField( 'instanceId', self::NOT_NULL ), + $this->expectedField( 'id', static::NOT_NULL ), + $this->expectedField( 'instanceId', static::NOT_NULL ), $this->expectedField( 'order', 0 ), $this->expectedField( 'enabled', true ), $this->expectedNode( @@ -437,8 +437,8 @@ public function testAddMethodToShippingZoneMutation() { 'node', [ $this->expectedField( 'id', $this->toRelayId( 'shipping_method', 'flat_rate' ) ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'title', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'title', static::NOT_NULL ), ] ) ], @@ -449,8 +449,8 @@ public function testAddMethodToShippingZoneMutation() { $this->expectedObject( 'addMethodToShippingZone.method', [ - $this->expectedField( 'id', self::NOT_NULL ), - $this->expectedField( 'instanceId', self::NOT_NULL ), + $this->expectedField( 'id', static::NOT_NULL ), + $this->expectedField( 'instanceId', static::NOT_NULL ), $this->expectedField( 'order', 0 ), $this->expectedField( 'enabled', true ), $this->expectedNode( @@ -464,8 +464,8 @@ public function testAddMethodToShippingZoneMutation() { 'node', [ $this->expectedField( 'id', $this->toRelayId( 'shipping_method', 'flat_rate' ) ), - $this->expectedField( 'databaseId', self::NOT_NULL ), - $this->expectedField( 'title', self::NOT_NULL ), + $this->expectedField( 'databaseId', static::NOT_NULL ), + $this->expectedField( 'title', static::NOT_NULL ), ] ) ] @@ -568,7 +568,7 @@ public function testUpdateMethodOnShippingZoneMutation() { [ $this->expectedField( 'id', $this->toRelayId( 'shipping_zone_method', $instance_id ) ), $this->expectedField( 'instanceId', $instance_id ), - $this->expectedField( 'order', self::NOT_NULL ), + $this->expectedField( 'order', static::NOT_NULL ), $this->expectedField( 'enabled', true ), $this->expectedNode( 'settings', @@ -588,7 +588,7 @@ public function testUpdateMethodOnShippingZoneMutation() { [ $this->expectedField( 'id', $this->toRelayId( 'shipping_zone_method', $instance_id ) ), $this->expectedField( 'instanceId', $instance_id ), - $this->expectedField( 'order', self::NOT_NULL ), + $this->expectedField( 'order', static::NOT_NULL ), $this->expectedField( 'enabled', true ), $this->expectedNode( 'settings', @@ -655,7 +655,7 @@ public function testRemoveMethodFromShippingZoneMutation() { 'removeMethodFromShippingZone.shippingZone', [ $this->expectedField( 'id', $this->toRelayId( 'shipping_zone', $shipping_zone->get_id() ) ), - $this->expectedField( 'methods.edges', self::IS_FALSY ), + $this->expectedField( 'methods.edges', static::IS_FALSY ), ] ), $this->expectedObject( diff --git a/tests/wpunit/ShippingZoneQueriesTest.php b/tests/wpunit/ShippingZoneQueriesTest.php index 34bc934e..c689e034 100644 --- a/tests/wpunit/ShippingZoneQueriesTest.php +++ b/tests/wpunit/ShippingZoneQueriesTest.php @@ -97,11 +97,11 @@ public function testShippingZoneQuery() { [ $this->expectedField( 'id', 'cost' ), $this->expectedField( 'label', 'Cost' ), - $this->expectedField( 'description', self::NOT_FALSY ), + $this->expectedField( 'description', static::NOT_FALSY ), $this->expectedField( 'type', 'TEXT' ), $this->expectedField( 'value', '10' ), - $this->expectedField( 'default', self::IS_NULL ), - $this->expectedField( 'placeholder', self::IS_NULL ), + $this->expectedField( 'default', static::IS_NULL ), + $this->expectedField( 'placeholder', static::IS_NULL ), ], ) ], @@ -134,7 +134,7 @@ public function testShippingZonesQuery() { * Confirm permission check is working */ $response = $this->graphql( compact( 'query' ) ); - $this->assertQuerySuccessful( $response, [ $this->expectedField( 'shippingZones.nodes', self::IS_FALSY ) ] ); + $this->assertQuerySuccessful( $response, [ $this->expectedField( 'shippingZones.nodes', static::IS_FALSY ) ] ); // Login as shop manager. $this->loginAsShopManager(); diff --git a/tests/wpunit/TaxClassQueriesTest.php b/tests/wpunit/TaxClassQueriesTest.php index cdc3052a..ba374043 100644 --- a/tests/wpunit/TaxClassQueriesTest.php +++ b/tests/wpunit/TaxClassQueriesTest.php @@ -17,7 +17,7 @@ public function testTaxClassesQuery() { // Execute the request expecting failure due to missing permissions. $response = $this->graphql( compact( 'query' ) ); - $this->assertQuerySuccessful( $response, [ $this->expectedField( 'taxClasses.nodes', self::IS_FALSY ) ] ); + $this->assertQuerySuccessful( $response, [ $this->expectedField( 'taxClasses.nodes', static::IS_FALSY ) ] ); // Login as shop manager. $this->loginAsShopManager(); diff --git a/tests/wpunit/TaxRateMutationsTest.php b/tests/wpunit/TaxRateMutationsTest.php index c91338ac..99e25165 100644 --- a/tests/wpunit/TaxRateMutationsTest.php +++ b/tests/wpunit/TaxRateMutationsTest.php @@ -58,7 +58,7 @@ class 'createTaxRate.taxRate', [ $this->expectedField( 'id', self::NOT_NULL ), - $this->expectedField( 'rate', self::NOT_FALSY ), + $this->expectedField( 'rate', static::NOT_FALSY ), $this->expectedField( 'country', 'US' ), $this->expectedField( 'state', 'CA' ), $this->expectedField( 'postcode', '67890' ), @@ -138,7 +138,7 @@ class 'updateTaxRate.taxRate', [ $this->expectedField( 'id', $this->toRelayId( 'tax_rate', $tax_rate_id ) ), - $this->expectedField( 'rate', self::NOT_FALSY ), + $this->expectedField( 'rate', static::NOT_FALSY ), $this->expectedField( 'country', 'US' ), $this->expectedField( 'state', 'NY' ), $this->expectedField( 'postcodes.0', '54321' ), @@ -203,7 +203,7 @@ class 'deleteTaxRate.taxRate', [ $this->expectedField( 'id', $this->toRelayId( 'tax_rate', $tax_rate->tax_rate_id ) ), - $this->expectedField( 'rate', self::NOT_FALSY ), + $this->expectedField( 'rate', static::NOT_FALSY ), $this->expectedField( 'country', 'US' ), $this->expectedField( 'state', 'TX' ), $this->expectedField( 'class', 'ZERO_RATE' ), diff --git a/tests/wpunit/TaxRateQueriesTest.php b/tests/wpunit/TaxRateQueriesTest.php index c0552798..53913fa2 100644 --- a/tests/wpunit/TaxRateQueriesTest.php +++ b/tests/wpunit/TaxRateQueriesTest.php @@ -7,12 +7,12 @@ public function expectedTaxRateData( $rate_id ) { return [ $this->expectedField( 'taxRate.id', $this->toRelayId( 'tax_rate', $rate_id ) ), $this->expectedField( 'taxRate.databaseId', absint( $rate->tax_rate_id ) ), - $this->expectedField( 'taxRate.country', ! empty( $rate->tax_rate_country ) ? $rate->tax_rate_country : self::IS_NULL ), - $this->expectedField( 'taxRate.state', ! empty( $rate->tax_rate_state ) ? $rate->tax_rate_state : self::IS_NULL ), + $this->expectedField( 'taxRate.country', ! empty( $rate->tax_rate_country ) ? $rate->tax_rate_country : static::IS_NULL ), + $this->expectedField( 'taxRate.state', ! empty( $rate->tax_rate_state ) ? $rate->tax_rate_state : static::IS_NULL ), $this->expectedField( 'taxRate.postcode', ! empty( $rate->tax_rate_postcode ) ? $rate->tax_rate_postcode : '*' ), $this->expectedField( 'taxRate.city', ! empty( $rate->tax_rate_city ) ? $rate->tax_rate_city : '*' ), - $this->expectedField( 'taxRate.rate', ! empty( $rate->tax_rate ) ? $rate->tax_rate : self::IS_NULL ), - $this->expectedField( 'taxRate.name', ! empty( $rate->tax_rate_name ) ? $rate->tax_rate_name : self::IS_NULL ), + $this->expectedField( 'taxRate.rate', ! empty( $rate->tax_rate ) ? $rate->tax_rate : static::IS_NULL ), + $this->expectedField( 'taxRate.name', ! empty( $rate->tax_rate_name ) ? $rate->tax_rate_name : static::IS_NULL ), $this->expectedField( 'taxRate.priority', absint( $rate->tax_rate_priority ) ), $this->expectedField( 'taxRate.compound', (bool) $rate->tax_rate_compound ), $this->expectedField( 'taxRate.shipping', (bool) $rate->tax_rate_shipping ), @@ -129,7 +129,7 @@ class // Execute the request expecting failure due to missing permissions. $response = $this->graphql( compact( 'query' ) ); - $this->assertQuerySuccessful( $response, [ $this->expectedField( 'taxRates.nodes', self::IS_FALSY ) ] ); + $this->assertQuerySuccessful( $response, [ $this->expectedField( 'taxRates.nodes', static::IS_FALSY ) ] ); // Login as shop manager. $this->loginAsShopManager(); diff --git a/tests/wpunit/UnsupportedProductTypeTest.php b/tests/wpunit/UnsupportedProductTypeTest.php index 28241470..700278c6 100644 --- a/tests/wpunit/UnsupportedProductTypeTest.php +++ b/tests/wpunit/UnsupportedProductTypeTest.php @@ -15,10 +15,10 @@ public function testUnsupportedProductTypeFailsWhenDisabled() { } '; - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product', self::IS_NULL ), + $this->expectedField( 'post', static::IS_NULL ), ]; $this->assertQueryError( $response, $expected ); @@ -43,10 +43,10 @@ public function testUnsupportedProductTypePassesWhenEnabled() { } '; - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedField( 'product.type', 'UNSUPPORTED' ), ]; @@ -63,7 +63,7 @@ public function testUnsupportedProductTypePassesWhenEnabled() { $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'unsupportedProduct.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'unsupportedProduct.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedField( 'unsupportedProduct.type', 'UNSUPPORTED' ), ]; diff --git a/tests/wpunit/UpdateSessionMutationTest.php b/tests/wpunit/UpdateSessionMutationTest.php index 823bb551..bd48d401 100644 --- a/tests/wpunit/UpdateSessionMutationTest.php +++ b/tests/wpunit/UpdateSessionMutationTest.php @@ -50,7 +50,7 @@ public function testUpdateSessionMutation() { $this->expectedField( 'value', 'test-value' ), ] ), - $this->expectedField( 'updateSession.customer.id', $this->toRelayId( 'customer', $registered ) ), + $this->expectedField( 'updateSession.customer.id', $this->toRelayId( 'user', $registered ) ), $this->expectedObject( 'updateSession.customer.session.#', [ diff --git a/tests/wpunit/VariationAttributeQueriesTest.php b/tests/wpunit/VariationAttributeQueriesTest.php index 1e5808bd..62b04d2f 100644 --- a/tests/wpunit/VariationAttributeQueriesTest.php +++ b/tests/wpunit/VariationAttributeQueriesTest.php @@ -103,10 +103,10 @@ public function testProductVariationToVariationAttributeQuery() { * * Test query and results */ - $variables = [ 'id' => $this->toRelayId( 'product_variation', $variation_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $variation_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'productVariation.id', $this->toRelayId( 'product_variation', $variation_id ) ), + $this->expectedField( 'productVariation.id', $this->toRelayId( 'post', $variation_id ) ), $this->expectedObject( 'productVariation.attributes', $this->expectedAttributes( $variation_id ) ), ]; @@ -142,10 +142,10 @@ public function testVariableProductToVariationAttributeQuery() { * * Test query and results */ - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedObject( 'product.defaultAttributes', $this->expectedAttributes( $product_id ) ), ]; @@ -212,10 +212,10 @@ static function ( $data, $index ) { * * Test query and results */ - $variables = [ 'id' => $this->toRelayId( 'product', $product_id ) ]; + $variables = [ 'id' => $this->toRelayId( 'post', $product_id ) ]; $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'product.id', $this->toRelayId( 'product', $product_id ) ), + $this->expectedField( 'product.id', $this->toRelayId( 'post', $product_id ) ), $this->expectedObject( 'product.defaultAttributes', $this->expectedDefaultAttributes( $product_id ) ), ];