Files
wp-graphql-woocommerce/tests/wpunit/IntrospectionQueryTest.php
T

45 lines
1.1 KiB
PHP
Raw Normal View History

2020-01-28 13:56:58 -05:00
<?php
class IntrospectionQueryTest extends \Codeception\TestCase\WPTestCase
{
public function setUp() {
// before
parent::setUp();
// your set up methods here
}
public function tearDown() {
// your tear down methods here
// then
parent::tearDown();
}
// Validate schema.
public function testSchema() {
try {
2020-01-28 14:07:33 -05:00
$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-06-19 18:44:21 -04:00
2020-01-28 13:56:58 -05:00
// Fail upon throwing
$this->assertTrue( false );
}
}
// Test introspection query.
public function testIntrospectionQuery() {
2020-06-19 18:44:21 -04:00
$query = \GraphQL\Type\Introspection::getIntrospectionQuery();
2020-01-28 13:56:58 -05:00
$results = graphql( array( 'query' => $query ) );
$this->assertArrayNotHasKey('errors', $results );
}
2020-06-19 18:44:21 -04:00
}