Files
wp-graphql-woocommerce/tests/wpunit/IntrospectionQueryTest.php
Dovid LevineandGitHub e96236696f chore: bump deps to meet actual requirements and lint for WPCS 3.0 (#816)
* chore: bump min versions to actual and update deps

* chore: fix multiple empty lines at EOF

* chore: preincrement when standalone (phpcs)

* fix: use `printf` instead of `echo sprintf` [phpcs]

* chore: avoid lonely `if()` in `else{}` [phpcs]

* chore: avoid reserved keywords as param names [phpcs]

* chore: remove unused callback params [phpcs]

* chore: remove more unused callback params [phpcs]

* chore: apply lints to tests

* chore: update ruleset for PHPCS 3.0

* texts: restore $last_request_headers
2023-11-30 08:41:32 -05:00

42 lines
1.0 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 = [];
}
$settings['public_introspection_enabled'] = 'on';
update_option( 'graphql_general_settings', $settings );
\WPGraphQL::clear_schema();
}
// 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( [ 'query' => $query ] );
$this->assertArrayNotHasKey( 'errors', $results );
}
}