Fix test on CalendarType: use the real IdToEntityDataTransformer, mocking the repository

This commit is contained in:
2023-08-28 15:22:08 +02:00
parent 2c83b4c912
commit 667104a595
4 changed files with 38 additions and 15 deletions

View File

@@ -34,8 +34,11 @@ class IdToEntityDataTransformer implements DataTransformerInterface
/**
* @param Closure $getId
*/
public function __construct(private readonly ObjectRepository $repository, private readonly bool $multiple = false, ?callable $getId = null)
{
public function __construct(
private readonly ObjectRepository $repository,
private readonly bool $multiple = false,
?callable $getId = null
) {
$this->getId = $getId ?? static fn (object $o) => $o->getId();
}

View File

@@ -24,11 +24,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
class PrivateCommentType extends AbstractType
{
protected UserInterface $user;
public function __construct(TokenStorageInterface $tokenStorage, protected PrivateCommentDataMapper $dataMapper)
public function __construct(protected PrivateCommentDataMapper $dataMapper)
{
$this->user = $tokenStorage->getToken()->getUser();
}
public function buildForm(FormBuilderInterface $builder, array $options)