2024-07-10 17:05:28 +00:00
|
|
|
<?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');
|
2024-09-15 20:11:42 +00:00
|
|
|
|
|
|
|
$crawler = $this->client->request(
|
|
|
|
'GET',
|
|
|
|
'/username',
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertResponseStatusCodeSame(200);
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$crawler->filter('#user_name_form_username')
|
|
|
|
->last()
|
|
|
|
->attr('value', ''),
|
|
|
|
'Testing-1'
|
|
|
|
);
|
|
|
|
|
2024-07-10 17:05:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 '';
|
|
|
|
}
|
|
|
|
}
|