public static function serializerDataProvider(): \Generator
{ yield ['{{ object|serialize }}', '{"name":"howdy","title":"fixture"}'
];
yield ['{{ object|serialize(\'yaml\') }}', '{ name: howdy, title: fixture }'
];
yield ['{{ object|serialize(\'yaml\', {groups: \'read\'}) }}', '{ name: howdy }'
];
} private function getTwig(string
$template): Environment
{ $meta =
new ClassMetadataFactory(new AnnotationLoader());
$runtime =
new SerializerRuntime(new Serializer([new ObjectNormalizer($meta)],
[new JsonEncoder(),
new YamlEncoder()]));
$mockRuntimeLoader =
$this->
createMock(RuntimeLoaderInterface::
class);
$mockRuntimeLoader ->
method('load'
) ->
willReturnMap([ ['Symfony\Bridge\Twig\Extension\SerializerRuntime',
$runtime],
]) ;
$twig =
new Environment(new ArrayLoader(['template' =>
$template]));
$twig->
addExtension(new SerializerExtension());