ebs/tests/Functional/Controller/Security/AccountCreateActionStep2UserTest.php
Loïc Vernet 32d91e49a0
Symfony 6.4 update (#590)
* symfony 6.3: removed sensio/framework-extra-bundle

* symfony 6.3: update

* Symfony 6.3.1 update

* chore: composer up

* symfony 6.4 update

* cs: php-code-fixer update

* fix composer.lock

* add php-http required dependencies

* Fix Stan and CS

---------

Co-authored-by: Jérôme Tanghe <jerome.tanghe@les-tilleuls.coop>
2024-10-08 09:50:06 +02:00

54 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Functional\Controller\Security;
use App\Test\ContainerRepositoryTrait;
use App\Test\KernelTrait;
use App\Tests\TestReference;
use Hautelook\AliceBundle\PhpUnit\ReloadDatabaseTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\String\ByteString;
/**
* @see AccountCreateController
*/
final class AccountCreateActionStep2UserTest extends WebTestCase
{
use ContainerRepositoryTrait;
use ReloadDatabaseTrait;
use KernelTrait;
private const ROUTE = '/fr/compte/creer-mon-compte-etape-2/';
public function testUserNotFoundException(): void
{
$client = self::createClient();
$client->request('GET', self::ROUTE.'foobar');
self::assertResponseRedirects();
$client->followRedirect();
self::assertResponseIsSuccessful();
self::assertSelectorTextContains('body', 'app.controller.security.account_create_controller.step2.user_not_found.warning');
}
public function testFormSubmitUserSuccess(): void
{
$client = self::createClient();
$crawler = $client->request('GET', self::ROUTE.TestReference::USER_12_CONFIRMATION_TOKEN);
$form = $crawler->selectButton('account_create_step2_form_submit')->form();
$password = ByteString::fromRandom(13);
$client->submit($form, [
$form->getName().'[type]' => 'user',
$form->getName().'[firstname]' => 'Foo',
$form->getName().'[lastname]' => 'Bar',
$form->getName().'[plainPassword][first]' => $password,
$form->getName().'[plainPassword][second]' => $password,
$form->getName().'[gdpr]' => 1,
]);
self::assertResponseRedirects();
$client->followRedirect();
self::assertResponseIsSuccessful();
}
}