Added dependency plugins

This commit is contained in:
Moris Zen
2018-06-25 00:00:37 +02:00
parent 720a1c31a4
commit f069f6782f
698 changed files with 289637 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
<?php
$I = new FunctionalTester( $scenario );
$I->wantTo('Get public data without passing authentication headers');
/**
* Make sure there's a post in the database to query for. If there was no data,
* we'd have some issues.
*/
$I->havePostInDatabase([
'post_type' => 'post',
'post_status' => 'publish',
'post_title' => 'test post',
'post_content' => 'test post content'
]);
/**
* Set the content-type so we get a proper response from the API
*/
$I->haveHttpHeader( 'Content-Type', 'application/json' );
$I->sendPOST( 'http://wpgraphql.test/graphql', json_encode([
'query' => '
{
posts {
edges {
node {
id
title
link
date
}
}
}
}'
]) );
$I->seeResponseCodeIs( 200 );
$I->seeResponseIsJson();
$response = $I->grabResponse();
$response_array = json_decode( $response, true );
/**
* Make sure query is valid and has no errors
*/
$I->assertArrayNotHasKey( 'errors', $response_array );
/**
* Make sure response is properly returning data as expected
*/
$I->assertArrayHasKey( 'data', $response_array );
/**
* Make sure there is a post returned with the data we requested
*/
$I->assertNotEmpty( $response_array['data']['posts']['edges'][0]['node']['id'] );
$I->assertNotEmpty( $response_array['data']['posts']['edges'][0]['node']['title'] );
$I->assertNotEmpty( $response_array['data']['posts']['edges'][0]['node']['link'] );
$I->assertNotEmpty( $response_array['data']['posts']['edges'][0]['node']['date'] );

View File

@@ -0,0 +1,62 @@
<?php
$I = new FunctionalTester( $scenario );
$I->wantTo( 'Get posts with different post_status' );
/**
* Clear posts table.
*/
$I->dontHavePostInDatabase([], true);
$test_posts_statuses = ['publish', 'draft', 'future'];
foreach ($test_posts_statuses as $post_status) {
// Add post for each type.
$I->havePostInDatabase( [
'post_type' => 'post',
'post_status' => $post_status,
'post_title' => "test {$post_status} post",
'post_content' => "test {$post_status} content"
] );
}
/**
* Set the content-type so we get a proper response from the API
*/
$I->haveHttpHeader( 'Content-Type', 'application/json' );
/**
* Query for only posts with a status of published and draft.
*/
$I->sendPOST( 'http://wpgraphql.test/graphql', json_encode( [
'query' => '
{
posts( where: { stati: [ PUBLISH, DRAFT ] } ){
edges {
node {
title
status
}
}
}
}'
] ) );
$I->seeResponseCodeIs( 200 );
$I->seeResponseIsJson();
$response = $I->grabResponse();
$response_array = json_decode( $response, true );
/**
* Make sure query is valid and has no errors
*/
$I->assertArrayNotHasKey( 'errors', $response_array );
/**
* Make sure response is properly returning data as expected
*/
$I->assertArrayHasKey( 'data', $response_array );
// Only 2 posts are returned
$I->assertEquals( 2, count( $response_array['data']['posts']['edges'] ) );
$I->assertEquals( 'test publish post', $response_array['data']['posts']['edges'][0]['node']['title'] );
$I->assertEquals( 'test draft post', $response_array['data']['posts']['edges'][1]['node']['title'] );