mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Feature: Allow to filter periods to reassign by postal code
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Form\Type\DataTransformer\PostalCodeToIdTransformer;
|
||||
use Chill\MainBundle\Form\Type\PickPostalCodeType;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PickPostalCodeTypeTest extends TypeTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testSubmitValidData(): void
|
||||
{
|
||||
$form = $this->factory->create(PickPostalCodeType::class, null);
|
||||
|
||||
$form->submit(['1']);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
|
||||
$this->assertEquals(1, $form->getData()->getId());
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
$postalCodeRepository = $this->prophesize(PostalCodeRepositoryInterface::class);
|
||||
$postalCodeRepository->find(Argument::type('string'))
|
||||
->will(static function ($args) {
|
||||
$postalCode = new PostalCode();
|
||||
$reflectionClass = new ReflectionClass($postalCode);
|
||||
$id = $reflectionClass->getProperty('id');
|
||||
$id->setAccessible(true);
|
||||
$id->setValue($postalCode, (int) $args[0]);
|
||||
|
||||
return $postalCode;
|
||||
});
|
||||
|
||||
$type = new PickPostalCodeType(
|
||||
new PostalCodeToIdTransformer(
|
||||
$postalCodeRepository->reveal()
|
||||
)
|
||||
);
|
||||
|
||||
return [
|
||||
new PreloadedExtension([$type], []),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user