feat: offer a newsletter opt-in for the other participants
addresses #869etn6c5
This commit is contained in:
1 parent
96b7b3f451
commit
876e69e62c
10 files changed
+598
-71
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\BookingCreateStep4Type;
|
||||
use App\Form\Model\BookingDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\Forms;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
||||
class BookingCreateStep4TypeTest extends TestCase
|
||||
{
|
||||
public function testCompanionOptInIsAbsentByDefault(): void
|
||||
{
|
||||
$form = $this->createForm();
|
||||
|
||||
self::assertFalse($form->has('companionNewsletterOptIn'));
|
||||
}
|
||||
|
||||
public function testCompanionOptInIsAddedWhenTheOptionIsOn(): void
|
||||
{
|
||||
$form = $this->createForm(['show_companion_newsletter_opt_in' => true]);
|
||||
|
||||
self::assertTrue($form->has('companionNewsletterOptIn'));
|
||||
self::assertFalse($form->get('companionNewsletterOptIn')->isRequired());
|
||||
}
|
||||
|
||||
public function testCompanionOptInIsIndependentOfTheApplicantOptIn(): void
|
||||
{
|
||||
$form = $this->createForm(['show_companion_newsletter_opt_in' => true]);
|
||||
|
||||
self::assertFalse($form->has('newsletterOptIn'));
|
||||
self::assertTrue($form->has('companionNewsletterOptIn'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @return FormInterface<mixed>
|
||||
*/
|
||||
private function createForm(array $options = []): FormInterface
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->id = 123;
|
||||
|
||||
return Forms::createFormFactoryBuilder()
|
||||
->addExtension(new ValidatorExtension(Validation::createValidator()))
|
||||
->addExtension(new PreloadedExtension([new BookingCreateStep4Type('https://example.com/agb')], []))
|
||||
->getFormFactory()
|
||||
->create(BookingCreateStep4Type::class, new BookingDto($travel, 77), $options);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user