Files

42 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2020-01-28 13:56:58 -05:00
<?php
2020-10-14 20:33:55 -04:00
class IntrospectionQueryTest extends \Codeception\TestCase\WPTestCase {
public function setUp(): void {
// before
2020-10-13 15:01:44 -04:00
parent::setUp();
2020-01-28 13:56:58 -05:00
2020-10-13 15:01:44 -04:00
$settings = get_option( 'graphql_general_settings' );
2020-10-14 20:33:55 -04:00
if ( ! $settings ) {
$settings = [];
2020-10-14 20:33:55 -04:00
}
2020-10-13 15:01:44 -04:00
$settings['public_introspection_enabled'] = 'on';
update_option( 'graphql_general_settings', $settings );
\WPGraphQL::clear_schema();
}
2020-01-28 13:56:58 -05:00
// Validate schema.
public function testSchema() {
try {
$request = new \WPGraphQL\Request();
$request->schema->assertValid();
2020-01-28 13:56:58 -05:00
// Assert true upon success.
$this->assertTrue( true );
} catch ( \GraphQL\Error\InvariantViolation $e ) {
// use --debug flag to view.
codecept_debug( $e->getMessage() );
2020-01-28 13:56:58 -05:00
// Fail upon throwing
$this->assertTrue( false );
}
}
2020-01-28 13:56:58 -05:00
// Test introspection query.
public function testIntrospectionQuery() {
$query = \GraphQL\Type\Introspection::getIntrospectionQuery();
$results = graphql( [ 'query' => $query ] );
2020-06-19 18:44:21 -04:00
$this->assertArrayNotHasKey( 'errors', $results );
}
2020-06-19 18:44:21 -04:00
}