serverRequestFactory = $this->objectManager->get(ServerRequestFactoryInterface::class); } /** * @test */ public function itRespondsToRequestsWithTheConfiguredHeader(): void { $request = $this->serverRequestFactory->createServerRequest('GET', 'dummyUrl'); $request = $request ->withHeader('X-Translation-Request', 'DigiComp.FlowTranslationEndpoint:Test|.*') ->withHeader('Accept-Language', 'en'); $response = $this->browser->sendRequest($request); static::assertEquals( '{"DigiComp.FlowTranslationEndpoint:Test":{"key1":"en_key1"}}', (string)$response->getBody() ); $request = $this->serverRequestFactory->createServerRequest('GET', 'dummyUrl'); $request = $request ->withHeader('X-Translation-Request', 'DigiComp.FlowTranslationEndpoint:Test|.*') ->withHeader('Accept-Language', 'de'); $response = $this->browser->sendRequest($request); static::assertEquals( '{"DigiComp.FlowTranslationEndpoint:Test":{"key1":"de_key1"}}', (string)$response->getBody() ); } /** * @test */ public function itRespondsToConfiguredRoute(): void { $request = $this->serverRequestFactory->createServerRequest('GET', 'testing/translate'); $request = $request ->withQueryParams(['idPatterns' => 'DigiComp.FlowTranslationEndpoint:Test|.*']) ->withHeader('Accept-Language', 'en'); $response = $this->browser->sendRequest($request); static::assertEquals( '{"DigiComp.FlowTranslationEndpoint:Test":{"key1":"en_key1"}}', (string)$response->getBody() ); } }