futtern/tests/Feature/Controller/HomeControllerTest.php
lubiana 9c98735db7
All checks were successful
/ ls (pull_request) Successful in 1m27s
/ ls (push) Successful in 1m24s
/ ls (release) Successful in 49s
migrate test cases to use pestphp syntax
2025-02-01 22:37:07 +01:00

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);