71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Tests\Feature\Controller;
|
|
|
|
use App\Controller\HomeController;
|
|
use App\Form\UserNameFormType;
|
|
|
|
use function describe;
|
|
use function test;
|
|
|
|
describe(HomeController::class, function (): void {
|
|
|
|
test('index', function (): void {
|
|
$this->client->request(
|
|
'GET',
|
|
'/'
|
|
);
|
|
|
|
$this->assertResponseStatusCodeSame(302);
|
|
$this->assertResponseHeaderSame('Location', '/food/order/list');
|
|
|
|
});
|
|
|
|
test('username', function (): void {
|
|
$this->client->request(
|
|
'GET',
|
|
'/username',
|
|
);
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
|
|
$this->client->submitForm('Save', [
|
|
'user_name_form[username]' => 'Testing-1',
|
|
]);
|
|
$this->assertResponseStatusCodeSame(302);
|
|
$this->assertResponseHeaderSame('Location', '/food/order/list');
|
|
$this->assertResponseCookieValueSame('username', 'Testing-1');
|
|
|
|
$crawler = $this->client->request(
|
|
'GET',
|
|
'/username',
|
|
);
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
|
|
$this->assertSame(
|
|
$crawler->filter('#user_name_form_username')
|
|
->last()
|
|
->attr('value', ''),
|
|
'Testing-1'
|
|
);
|
|
|
|
});
|
|
|
|
test('username empty', function (): void {
|
|
$this->client->request(
|
|
'GET',
|
|
'/username',
|
|
);
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
|
|
$this->client->submitForm('Save', [
|
|
'user_name_form[username]' => '',
|
|
]);
|
|
$this->assertResponseStatusCodeSame(302);
|
|
$this->assertResponseHeaderSame('Location', '/food/order/list');
|
|
$this->assertResponseCookieValueSame('username', '');
|
|
});
|
|
})
|
|
->covers(HomeController::class, UserNameFormType::class);
|