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/composer.lock b/composer.lock index be089afe..e3c9e863 100644 --- a/composer.lock +++ b/composer.lock @@ -1128,16 +1128,16 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", "shasum": "" }, "require": { @@ -1184,7 +1184,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" }, "funding": [ { @@ -1200,7 +1200,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "szepeviktor/phpstan-wordpress", 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 09ccd4e9..6dd453ec 100644 --- a/includes/model/class-product.php +++ b/includes/model/class-product.php @@ -195,7 +195,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/wpunit/CartMutationsTest.php b/tests/wpunit/CartMutationsTest.php index af51deed..aa8db2ba 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'], diff --git a/tests/wpunit/CartQueriesTest.php b/tests/wpunit/CartQueriesTest.php index 4bb44c0c..86fe6c20 100644 --- a/tests/wpunit/CartQueriesTest.php +++ b/tests/wpunit/CartQueriesTest.php @@ -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..3f88a0ee 100644 --- a/tests/wpunit/CheckoutMutationTest.php +++ b/tests/wpunit/CheckoutMutationTest.php @@ -452,7 +452,7 @@ public function testCheckoutMutation() { ), $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 ), 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/CustomerQueriesTest.php b/tests/wpunit/CustomerQueriesTest.php index 5ea00562..a5d421f6 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() ), @@ -142,7 +142,7 @@ 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' ), @@ -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,7 +175,7 @@ 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( [ @@ -528,7 +528,7 @@ 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 ) ]; @@ -538,7 +538,7 @@ public function testCustomerAvailablePaymentMethodsField() { $this->loginAsShopManager(); $response = $this->graphql( compact( 'query', 'variables' ) ); $expected = [ - $this->expectedField( 'customer.id', $this->toRelayId( 'customer', $customer_id ) ), + $this->expectedField( 'customer.id', $this->toRelayId( 'user', $customer_id ) ), $this->expectedField( 'customer.availablePaymentMethods', self::IS_NULL ), ]; @@ -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,10 +645,10 @@ 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.id', $this->toRelayId( 'user', $customer_id ) ), $this->expectedField( 'customer.cartUrl', self::IS_NULL ), $this->expectedField( 'customer.cartNonce', self::IS_NULL ), $this->expectedField( 'customer.checkoutUrl', self::IS_NULL ), @@ -664,7 +664,7 @@ 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.id', $this->toRelayId( 'user', $customer_id ) ), $this->expectedField( 'customer.cartUrl', self::NOT_NULL ), $this->expectedField( 'customer.cartNonce', self::NOT_NULL ), $this->expectedField( 'customer.checkoutUrl', self::NOT_NULL ), 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..174bb216 100644 --- a/tests/wpunit/OrderItemQueriesTest.php +++ b/tests/wpunit/OrderItemQueriesTest.php @@ -301,11 +301,11 @@ function ( $item ) { $this->expectedField( 'totalTax', $this->maybe( $item->get_total_tax(), self::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() ) + ? $this->toRelayId( 'post', $item->get_variation_id() ) : self::IS_NULL ), ] diff --git a/tests/wpunit/OrderQueriesTest.php b/tests/wpunit/OrderQueriesTest.php index 940d2fab..446532a3 100644 --- a/tests/wpunit/OrderQueriesTest.php +++ b/tests/wpunit/OrderQueriesTest.php @@ -35,7 +35,7 @@ public function expectedOrderData( $order_id ) { $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 ) 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 606fcdf2..f93aa2e4 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() ), @@ -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' ) ); @@ -535,7 +535,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 @@ -688,12 +688,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 ), ]; @@ -841,7 +841,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 ); @@ -870,7 +870,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 ); @@ -895,7 +895,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 ); @@ -905,7 +905,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 ), ]; @@ -921,7 +921,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!) { @@ -1046,8 +1046,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 ), @@ -1056,8 +1056,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 ), @@ -1082,7 +1082,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 = ' @@ -1122,7 +1122,7 @@ public function testProductDownloads() { ] ); - $relay_id = $this->toRelayId( 'product', $product_id ); + $relay_id = $this->toRelayId( 'post', $product_id ); $query = ' query ( $id: ID! ) { @@ -1161,7 +1161,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! ) { @@ -1205,7 +1205,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! ) { @@ -1237,7 +1237,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 ) ] ); } @@ -1292,25 +1292,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 ) ] ); } @@ -1326,7 +1326,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 = ' @@ -1389,7 +1389,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, @@ -1472,7 +1472,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 ); @@ -1488,7 +1488,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' ) ); @@ -1575,7 +1575,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $normal_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $normal_product_id ) ] ), ]; @@ -1597,7 +1597,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 ); @@ -1618,7 +1618,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $both_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $both_product_id ) ] ), ]; @@ -1664,7 +1664,7 @@ public function testProductsQueryWithAttributesFilter() { $expected = [ $this->expectedNode( 'products.nodes', - [ 'id' => $this->toRelayId( 'product', $special_product_id ) ] + [ 'id' => $this->toRelayId( 'post', $special_product_id ) ] ), ]; @@ -1691,7 +1691,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 e7fdda8b..d7eceac1 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() ), @@ -78,7 +78,7 @@ public function expectedProductVariationData( $id ) { ), $this->expectedField( 'productVariation.hasAttributes', ! empty( $data->has_attributes() ) ? $data->has_attributes() : self::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 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 ); @@ -219,9 +219,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'] ) ) @@ -252,9 +252,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 ); @@ -266,7 +266,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. @@ -297,7 +297,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() ); @@ -387,9 +387,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 ); @@ -400,9 +400,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 ); @@ -413,9 +413,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/UnsupportedProductTypeTest.php b/tests/wpunit/UnsupportedProductTypeTest.php index 28241470..90e80050 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', self::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 ) ), ];