Files
wp-graphql-woocommerce/tests/wpunit/IntrospectionQueryTest.php
T
a7714d0cd2 Updates to be compatible with WPGraphQL v1.6.1 (#537)
* fix: Huge refactor across schema and unit tests

* - add shipping_method loader in class-core-schema-filters.php

* - Update class-wc-db-loader.php to respect the new SHIPPING_METHOD loader with a `load_shipping_method_from_id()` function

* - Convert Shipping_Method_Connection_Resolver to extend AbstractConnectionResolver

* - Replace resolver for Shipping Methods connection. Remove use of `resolveNode` and replace the resolver with the new connection class `get_connection()` call

* chore: Factory class refactored.

* - update the function that registers Product Types to the Schema to use the value from the `get_enabled_product_types()` as the Type name and the key as the fieldName

* chore: PaymentGatewayQueriesTest refactored.

* chore: WPCS compliance met

* chore: Syntax error fixed.

Co-authored-by: Jason Bahl <jasonbahl@mac.com>
2021-08-11 14:26:09 -04:00

50 lines
1.3 KiB
PHP

<?php
class IntrospectionQueryTest extends \Codeception\TestCase\WPTestCase {
public function setUp(): void {
// before
parent::setUp();
$settings = get_option( 'graphql_general_settings' );
if ( ! $settings ) {
$settings = array();
}
$settings['public_introspection_enabled'] = 'on';
update_option( 'graphql_general_settings', $settings );
\WPGraphQL::clear_schema();
}
public function tearDown(): void {
// your tear down methods here
// then
parent::tearDown();
}
// Validate schema.
public function testSchema() {
try {
$request = new \WPGraphQL\Request();
$request->schema->assertValid();
// Assert true upon success.
$this->assertTrue( true );
} catch (\GraphQL\Error\InvariantViolation $e) {
// use --debug flag to view.
codecept_debug( $e->getMessage() );
// Fail upon throwing
$this->assertTrue( false );
}
}
// Test introspection query.
public function testIntrospectionQuery() {
$query = \GraphQL\Type\Introspection::getIntrospectionQuery();
$results = graphql( array( 'query' => $query ) );
$this->assertArrayNotHasKey('errors', $results );
}
}