graphql-php/tests/Server/PsrResponseTest.php
2018-08-31 14:41:18 +02:00

26 lines
793 B
PHP

<?php
namespace GraphQL\Tests\Server;
use GraphQL\Executor\ExecutionResult;
use GraphQL\Server\Helper;
use GraphQL\Tests\Server\Psr7\PsrStreamStub;
use GraphQL\Tests\Server\Psr7\PsrResponseStub;
use PHPUnit\Framework\TestCase;
class PsrResponseTest extends TestCase
{
public function testConvertsResultToPsrResponse() : void
{
$result = new ExecutionResult(['key' => 'value']);
$stream = new PsrStreamStub();
$psrResponse = new PsrResponseStub();
$helper = new Helper();
/** @var PsrResponseStub $resp */
$resp = $helper->toPsrResponse($result, $psrResponse, $stream);
$this->assertSame(json_encode($result), $resp->body->content);
$this->assertSame(['Content-Type' => ['application/json']], $resp->headers);
}
}