Skip to content

Commit

Permalink
autoloader files rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Feb 27, 2021
1 parent a51cb59 commit 888ac96
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 8,015 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
"require-dev": {
"composer/installers": "^1.9",
"lucatume/wp-browser": "^2.6.",
"wp-graphql/wp-graphql-testcase": "^1.0",
"wp-graphql/wp-graphql-testcase": "^1.0.1",
"codeception/module-asserts": "^1.0",
"codeception/util-universalframework": "^1.0",
"codeception/module-rest": "^1.2",
"simpod/php-coveralls-mirror": "^3.0",
"stripe/stripe-php": "^7.28",
"wp-coding-standards/wpcs": "^2.3",
"johnpbloch/wordpress": "~5.3",
"wp-graphql/wp-graphql": "^1.1.4",
"wp-graphql/wp-graphql-jwt-authentication": "^0.4.1",
"wpackagist-plugin/wp-graphql": "^1.1.8",
"wpackagist-plugin/woocommerce": "^4.4",
"wpackagist-plugin/woocommerce-gateway-stripe": "^4.5",
"wpackagist-theme/twentytwentyone": "^1.0",
Expand Down
8 changes: 4 additions & 4 deletions includes/model/class-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,16 @@ protected function init() {
return ! is_null( $this->wc_data->is_sold_individually() ) ? $this->wc_data->is_sold_individually() : null;
},
'weight' => function() {
return ! is_null( $this->wc_data->get_weight() ) ? $this->wc_data->get_weight() : null;
return ! empty( $this->wc_data->get_weight() ) ? $this->wc_data->get_weight() : null;
},
'length' => function() {
return ! is_null( $this->wc_data->get_length() ) ? $this->wc_data->get_length() : null;
return ! empty( $this->wc_data->get_length() ) ? $this->wc_data->get_length() : null;
},
'width' => function() {
return ! is_null( $this->wc_data->get_width() ) ? $this->wc_data->get_width() : null;
return ! empty( $this->wc_data->get_width() ) ? $this->wc_data->get_width() : null;
},
'height' => function() {
return ! is_null( $this->wc_data->get_height() ) ? $this->wc_data->get_height() : null;
return ! empty( $this->wc_data->get_height() ) ? $this->wc_data->get_height() : null;
},
'shippingClassId' => function () {
return ! empty( $this->wc_data->get_image_id() ) ? $this->wc_data->get_shipping_class_id() : null;
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
<file>includes/</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>local/*</exclude-pattern>
<exclude-pattern>/tests/</exclude-pattern>
</ruleset>
55 changes: 28 additions & 27 deletions tests/wpunit/CartMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function testEmptyCartMutation() {
$product_id = $this->factory->product->createSimple();
$cart = \WC()->cart;
$cart_item_key = $cart->add_to_cart( $product_id, 1 );
$cart_item = \WC()->cart->get_cart_item( $cart_item_key );
$cart_item = $cart->get_cart_item( $cart_item_key );

$query = '
mutation( $input: EmptyCartInput! ) {
Expand Down Expand Up @@ -402,6 +402,7 @@ public function testEmptyCartMutation() {
'id' => $this->toRelayId( 'product', $cart_item['product_id'] ),
),
),
'variation' => null,
'quantity' => $cart_item['quantity'],
'subtotal' => wc_graphql_price( $cart_item['line_subtotal'] ),
'subtotalTax' => wc_graphql_price( $cart_item['line_subtotal_tax'] ),
Expand Down Expand Up @@ -474,14 +475,14 @@ public function testApplyCouponMutation() {
$response = $this->graphql( compact( 'query', 'variables' ) );

// Get updated cart item.
$cart_item = \WC()->cart->get_cart_item( $cart_item_key );
$cart_item = $cart->get_cart_item( $cart_item_key );

$this->assertQuerySuccessful(
$response,
array(
$this->expectedObject( 'applyCoupon.clientMutationId', 'someId' ),
$this->expectedNode(
'applyCoupon.cart.appliedCoupons.nodes',
'applyCoupon.cart.appliedCoupons',
array(
'code' => $coupon_code,
)
Expand Down Expand Up @@ -659,7 +660,7 @@ public function testRemoveCouponMutation() {
$response,
array(
$this->expectedObject( 'removeCoupons.clientMutationId', 'someId' ),
$this->expectedObject( 'removeCoupons.cart.appliedCoupons.0.code', $coupon_code ),
$this->expectedObject( 'removeCoupons.cart.appliedCoupons', 'null' ),
$this->expectedNode(
'removeCoupons.cart.contents.nodes',
array(
Expand Down Expand Up @@ -775,12 +776,12 @@ public function testAddToCartMutationErrors() {
cartItem {
key
product {
nodes {
node {
id
}
}
variation {
nodes {
node {
id
}
}
Expand Down Expand Up @@ -820,9 +821,9 @@ public function testAddToCartMutationErrors() {

public function testAddCartItemsMutationAndErrors() {
// Create variable product for later use.
$variation_ids = $this->variation->create( $this->product->create_variable() );
$product = \wc_get_product( $variation_ids['product'] );
$attribute = new WC_Product_Attribute();
$variation_ids = $this->factory->product_variation->createSome();
$product = \wc_get_product( $variation_ids['product'] );
$attribute = new WC_Product_Attribute();
$attribute->set_id( 0 );
$attribute->set_name( 'test' );
$attribute->set_options( array( 'yes', 'no' ) );
Expand All @@ -834,7 +835,7 @@ public function testAddCartItemsMutationAndErrors() {
$product->set_attributes( $attributes );
$product->save();

$product_one = $this->product->create_simple();
$product_one = $this->factory->product->createSimple();
$invalid_product = 1000;

$query = '
Expand Down Expand Up @@ -892,6 +893,10 @@ public function testAddCartItemsMutationAndErrors() {
'attributeName' => 'test',
'attributeValue' => 'yes',
),
array(
'attributeName' => 'color',
'attributeValue' => 'green',
),
)
)
),
Expand Down Expand Up @@ -930,7 +935,7 @@ public function testAddCartItemsMutationAndErrors() {
'addCartItems.cartErrors',
array(
'type' => 'INVALID_CART_ITEM',
'reasons' => array( 'test is a required field' ),
'reasons' => array( 'color and test are required fields' ),
'productId' => $variation_ids['product'],
'quantity' => 5,
'variationId' => $variation_ids['variations'][0],
Expand All @@ -956,24 +961,20 @@ public function testAddCartItemsMutationAndErrors() {

public function testFillCartMutationAndErrors() {
// Create products.
$product_one = $this->product->create_simple(
array( 'regular_price' => 100 )
);
$product_two = $this->product->create_simple(
array( 'regular_price' => 40 )
);
$product_one = $this->factory->product->createSimple( array( 'regular_price' => 100 ) );
$product_two = $this->factory->product->createSimple( array( 'regular_price' => 40 ) );

// Create coupons.
$coupon_code_one = wc_get_coupon_code_by_id(
$this->coupon->create(
array(
'amount' => 0.5,
'product_ids' => array( $product_one )
)
)
);
$this->factory->coupon->create(
array(
'amount' => 0.5,
'product_ids' => array( $product_one )
)
)
);
$coupon_code_two = wc_get_coupon_code_by_id(
$this->coupon->create(
$this->factory->coupon->create(
array(
'amount' => 0.2,
'product_ids' => array( $product_two )
Expand Down Expand Up @@ -1058,7 +1059,7 @@ public function testFillCartMutationAndErrors() {
$response,
array(
$this->expectedObject( 'fillCart.clientMutationId', 'someId' ),
$this->expectedNode( 'fillCart.cart.chosenShippingMethod', 'legacy_flat_rate' ),
$this->expectedNode( 'fillCart.cart.chosenShippingMethods', 'legacy_flat_rate' ),
$this->expectedNode(
'fillCart.cart.contents.nodes',
array(
Expand Down Expand Up @@ -1124,8 +1125,8 @@ public function testFillCartMutationAndErrors() {
'fillCart.cartErrors',
array(
'type' => 'INVALID_SHIPPING_METHOD',
'chosenMethod' => $invalid_shipping_method,
'package' => 1,
'chosenMethod' => $invalid_shipping_method
)
),
)
Expand Down
8 changes: 4 additions & 4 deletions tests/wpunit/CartQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public function getExpectedCartItemData( $path, $cart_item_key ) {
$item = $cart->get_cart_item( $cart_item_key );
return array(
$this->expectedObject( "{$path}.key", $item['key'] ),
$this->expectedObject( "{$path}.product.id", $this->toRelayId( 'product', $item['product_id'] ) ),
$this->expectedObject( "{$path}.product.databaseId", $item['product_id'] ),
$this->expectedObject( "{$path}.product.node.id", $this->toRelayId( 'product', $item['product_id'] ) ),
$this->expectedObject( "{$path}.product.node.databaseId", $item['product_id'] ),
$this->expectedObject(
"{$path}.variation.id",
"{$path}.variation.node.id",
! empty( $item['variation_id'] )
? $this->toRelayId( 'product_variation', $item['variation_id'] )
: 'NULL'
),
$this->expectedObject(
"{$path}.variation.databaseId",
"{$path}.variation.node.databaseId",
! empty( $item['variation_id'] ) ? $item['variation_id'] : 'NULL'
),
$this->expectedObject( "{$path}.quantity", $item['quantity'] ),
Expand Down
38 changes: 17 additions & 21 deletions tests/wpunit/ProductQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getExpectedProductData( $product_id ) {

return array(
$this->expectedObject( 'product.id', $this->toRelayId( 'product', $product_id ) ),
$this->expectedObject( 'product.productId', $product->get_id() ),
$this->expectedObject( 'product.databaseId', $product->get_id() ),
$this->expectedObject( 'product.name', $product->get_name() ),
$this->expectedObject( 'product.slug', $product->get_slug() ),
$this->expectedObject( 'product.date', $product->get_date_created()->__toString() ),
Expand Down Expand Up @@ -371,8 +371,11 @@ public function testProductTaxonomies() {
$this->expectedNode(
'product.productCategories.nodes',
array(
'name' => 'category-five',
'children' => array(
'name' => 'category-five',
'image' => null,
'display' => 'DEFAULT',
'menuOrder' => 0,
'children' => array(
'nodes' => array(
array( 'name' => 'category-six' ),
),
Expand Down Expand Up @@ -1241,7 +1244,7 @@ public function testProductGalleryImagesConnection() {
'post_content' => 'Lorem ipsum dolor...',
)
);
$product_id = $this->helper->create_simple(
$product_id = $this->factory->product->createSimple(
array( 'gallery_image_ids' => array( $image_id ) )
);

Expand All @@ -1257,23 +1260,16 @@ public function testProductGalleryImagesConnection() {
}
';

$variables = array( 'id' => $this->helper->to_relay_id( $product_id ) );
$actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
$expected = array(
'data' => array(
'product' => array (
'galleryImages' => array(
'nodes' => array(
array( 'id' => \GraphQLRelay\Relay::toGlobalId( 'post', $image_id ) )
)
)
),
),
$variables = array( 'id' => $this->toRelayId( 'product', $product_id ) );
$response = $this->graphql( compact( 'query', 'variables' ) );
$this->assertQuerySuccessful(
$response,
array(
$this->expectedNode(
'product.galleryImages.nodes',
array( 'id' => $this->toRelayId( 'post', $image_id ) )
)
)
);

// use --debug flag to view.
codecept_debug( $actual );

$this->assertEquals( $expected, $actual );
}
}
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit5eacf0c3882a5724168d223c2be9fedf::getLoader();
return ComposerAutoloaderInit648341988a21d33ec51fdb8a740ccacb::getLoader();
13 changes: 11 additions & 2 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => 'd7379a41e679eef76f221638e568076932e62ed9',
'reference' => 'a6f2c9f49b99ff4f8a13707bba2c21861e9c0813',
'name' => 'wp-graphql/wp-graphql-woocommerce',
),
'versions' =>
Expand All @@ -43,14 +43,23 @@ class InstalledVersions
),
'reference' => 'f42c9110abe98dd6cfe9053c49bc86acc70b2d23',
),
'webonyx/graphql-php' =>
array (
'pretty_version' => 'v14.4.0',
'version' => '14.4.0.0',
'aliases' =>
array (
),
'reference' => 'aab3d49181467db064b41429cde117a7589625fc',
),
'wp-graphql/wp-graphql-woocommerce' =>
array (
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'aliases' =>
array (
),
'reference' => 'd7379a41e679eef76f221638e568076932e62ed9',
'reference' => 'a6f2c9f49b99ff4f8a13707bba2c21861e9c0813',
),
),
);
Expand Down
Loading

0 comments on commit 888ac96

Please sign in to comment.