get(MessageFormatRegistry::class); self::assertInstanceOf(MessageFormatRegistry::class, $registry); self::assertTrue($registry->hasParser(MessageFormat::Icu)); self::assertTrue($registry->hasParser(MessageFormat::I18next)); self::assertTrue($registry->hasSerializer(MessageFormat::Icu)); self::assertTrue($registry->hasSerializer(MessageFormat::I18next)); } /** * L'enum décrit ce que le moteur PRÉTEND savoir faire ; le registre décrit ce * qu'il sait faire RÉELLEMENT. Les deux doivent coïncider, sans quoi l'écran * de création d'une plateforme proposerait un format dont la publication * échouerait ensuite systématiquement. */ public function testEnumCapabilitiesMatchRegisteredImplementations(): void { self::bootKernel(); $registry = self::getContainer()->get(MessageFormatRegistry::class); self::assertInstanceOf(MessageFormatRegistry::class, $registry); foreach (MessageFormat::cases() as $format) { self::assertSame( $format->supportsImport(), $registry->hasParser($format), sprintf('MessageFormat::%s->supportsImport() ne correspond pas au registre.', $format->name), ); self::assertSame( $format->supportsExport(), $registry->hasSerializer($format), sprintf('MessageFormat::%s->supportsExport() ne correspond pas au registre.', $format->name), ); } } public function testMissingSerializerFailsWithAnActionableMessage(): void { self::bootKernel(); $registry = self::getContainer()->get(MessageFormatRegistry::class); self::assertInstanceOf(MessageFormatRegistry::class, $registry); $this->expectException(\RuntimeException::class); $this->expectExceptionMessageMatches('/formats exportables/'); $registry->serializer(MessageFormat::Android); } }