Phred/tests/ProviderRouteTest.php

29 lines
873 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Phred\Tests;
use Nyholm\Psr7\ServerRequest;
use PHPUnit\Framework\TestCase;
final class ProviderRouteTest extends TestCase
{
public function testAppProviderRegistersRoute(): void
{
$root = dirname(__DIR__);
/** @var object $app */
$app = require $root . '/bootstrap/app.php';
$this->assertInstanceOf(\Phred\Http\Kernel::class, $app);
$request = new ServerRequest('GET', '/_phred/app');
$response = $app->handle($request);
$this->assertSame(200, $response->getStatusCode());
$this->assertSame('application/json', $response->getHeaderLine('Content-Type'));
$data = json_decode((string) $response->getBody(), true);
$this->assertIsArray($data);
$this->assertArrayHasKey('app', $data);
$this->assertTrue($data['app']);
}
}