Files
962410d265 fix: add model classes to type configs to better support query analyzer ID tracking (#874)
* - 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>
2024-08-06 18:54:18 -04:00

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 );
}
}