This commit is contained in:
19
tests/Feature/HomeControllerTest.php
Normal file
19
tests/Feature/HomeControllerTest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
it('returns status 200', function (): void {
|
||||
$response = get('/');
|
||||
$body = $response->getBody();
|
||||
$body->rewind();
|
||||
|
||||
expect($response->getStatusCode())->toBe(200);
|
||||
});
|
||||
|
||||
it('view is rendered', function (): void {
|
||||
$response = get('/');
|
||||
$body = $response->getBody();
|
||||
$body->rewind();
|
||||
|
||||
expect($body->getContents())->toBe('Welkom');
|
||||
});
|
||||
15
tests/Pest.php
Normal file
15
tests/Pest.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Laminas\Diactoros\ServerRequest;
|
||||
use League\Route\Router;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
function get(string $uri, array $headers = [], array $cookies = []): ResponseInterface
|
||||
{
|
||||
$router = app(Router::class);
|
||||
$request = new ServerRequest(uri: $uri, method: 'GET', headers: $headers, cookieParams: $cookies);
|
||||
|
||||
return $router->dispatch($request);
|
||||
}
|
||||
11
tests/TestCase.php
Normal file
11
tests/TestCase.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
}
|
||||
7
tests/Unit/ExampleTest.php
Normal file
7
tests/Unit/ExampleTest.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('example', function (): void {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
Reference in New Issue
Block a user