Skip to content

Commit

Permalink
chore: fix cleanup after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Aug 6, 2024
1 parent 06ed544 commit caeeff9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
8 changes: 7 additions & 1 deletion tests/_support/TestCase/WooGraphQLTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ protected function logout() {
*
* @return mixed
*/
protected function maybe( $possible, $default = static::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 {
Expand Down
56 changes: 28 additions & 28 deletions tests/wpunit/ProductsQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
),
];
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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
),
];
Expand All @@ -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 );
Expand Down Expand Up @@ -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'] ) )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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
),
Expand All @@ -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
),
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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
),
Expand All @@ -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
),
Expand Down

0 comments on commit caeeff9

Please sign in to comment.