futtern/tests/Controller/HomeControllerTest.php
lubiana 9afa7fe431
All checks were successful
/ ls (pull_request) Successful in 37s
/ ls (push) Successful in 32s
#29: add more tests
2024-07-10 22:18:56 +02:00

61 lines
1.4 KiB
PHP

<?php declare(strict_types=1);
namespace App\Tests\Controller;
use App\Tests\DbWebTest;
use Override;
final class HomeControllerTest extends DbWebTest
{
public function testIndex(): void
{
$this->client->request(
'GET',
'/'
);
self::assertResponseStatusCodeSame(302);
self::assertResponseHeaderSame('Location', '/food/order/list');
}
public function testSetUsername(): void
{
$this->client->request(
'GET',
'/username',
);
self::assertResponseStatusCodeSame(200);
$this->client->submitForm('Save', [
'user_name_form[username]' => 'Testing-1',
]);
self::assertResponseStatusCodeSame(302);
self::assertResponseHeaderSame('Location', '/food/order/list');
self::assertResponseCookieValueSame('username', 'Testing-1');
}
public function testRemoveUsername(): void
{
$this->client->request(
'GET',
'/username',
);
self::assertResponseStatusCodeSame(200);
$this->client->submitForm('Save', [
'user_name_form[username]' => '',
]);
self::assertResponseStatusCodeSame(302);
self::assertResponseHeaderSame('Location', '/food/order/list');
self::assertResponseCookieValueSame('username', '');
}
#[Override]
public function getEntityClass(): string
{
return '';
}
}