mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
* - remove several fields that are already registered by core when the post type is mapped to the schema * devops: Tests updated and coupon "salt" restored * chore: Linter & PHPStan compliance met * chore: Linter & PHPStan compliance met * devops: "self" replaced with "static" in cli tests * chore: fix cleanup after rebasing --------- Co-authored-by: Geoff Taylor <geoff@axistaylor.com>
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
class TaxClassQueriesTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGraphQLTestCase {
|
|
public function testTaxClassesQuery() {
|
|
// Create tax classes.
|
|
$tax_classes = $this->factory->tax_class->create_many( 2 );
|
|
|
|
// Prepare the request.
|
|
$query = '{
|
|
taxClasses {
|
|
nodes {
|
|
name
|
|
slug
|
|
}
|
|
}
|
|
}';
|
|
|
|
// Execute the request expecting failure due to missing permissions.
|
|
$response = $this->graphql( compact( 'query' ) );
|
|
$this->assertQuerySuccessful( $response, [ $this->expectedField( 'taxClasses.nodes', static::IS_FALSY ) ] );
|
|
|
|
// Login as shop manager.
|
|
$this->loginAsShopManager();
|
|
|
|
// Execute the request.
|
|
$response = $this->graphql( compact( 'query' ) );
|
|
$expected = [
|
|
$this->expectedNode(
|
|
'taxClasses.nodes',
|
|
[
|
|
$this->expectedField( 'name', $tax_classes[0]['name'] ),
|
|
$this->expectedField( 'slug', $tax_classes[0]['slug'] ),
|
|
]
|
|
),
|
|
$this->expectedNode(
|
|
'taxClasses.nodes',
|
|
[
|
|
$this->expectedField( 'name', $tax_classes[1]['name'] ),
|
|
$this->expectedField( 'slug', $tax_classes[1]['slug'] ),
|
|
]
|
|
),
|
|
];
|
|
|
|
// Validate the response.
|
|
$this->assertQuerySuccessful( $response, $expected );
|
|
}
|
|
}
|