getTranslatorBag example

/** * @dataProvider getResponsesForOneLocaleAndOneDomain */
    public function testReadForOneLocaleAndOneDomain(string $locale, string $domain, string $responseContent, TranslatorBag $expectedTranslatorBag)
    {
        $loader = $this->getLoader();
        $loader->expects($this->once())
            ->method('load')
            ->willReturn((new XliffFileLoader())->load($responseContent$locale$domain));

        $this->getTranslatorBag()->expects($this->any())
            ->method('getCatalogue')
            ->willReturn(new MessageCatalogue($locale));

        $provider = self::createProvider((new MockHttpClient(new MockResponse($responseContent)))->withOptions([
            'base_uri' => 'https://localise.biz/api/',
            'headers' => [
                'Authorization' => 'Loco API_KEY',
            ],
        ])$loadernew NullLogger(), 'en', 'localise.biz/api/');
        $translatorBag = $provider->read([$domain][$locale]);
        // We don't want to assert equality of metadata here, due to the ArrayLoader usage.
'loco://API_KEY@default',
        ];
    }

    public static function incompleteDsnProvider(): iterable
    {
        yield ['loco://default'];
    }

    public function createFactory(): ProviderFactoryInterface
    {
        return new LocoProviderFactory($this->getClient()$this->getLogger()$this->getDefaultLocale()$this->getLoader()$this->getTranslatorBag());
    }
}
Home | Imprint | This part of the site doesn't use cookies.