middleware = new LocaleMiddleware($container); } /** * Test the testLocale() function. * * @return void */ public function testTestLocale() { $this->markTestSkipped('For some reason, this test fails on Travis even if the fr_FR locale is installed.'); $locale = [ 'language' => 'fr', 'region' => 'FR', ]; $this->assertEquals('fr_FR', $this->middleware->testLocale($locale)); } /** * Test the testLocale() function with an unsupported locale. * * @return void */ public function testLocaleWithWrongLocale() { $locale = [ 'language' => 'foo', 'region' => 'BAR', ]; $this->assertNull($this->middleware->testLocale($locale)); $this->assertNull($this->middleware->testLocale([])); } /** * Mock function that does nothing. * * @return void */ public function nothing() { } /** * Test the __invoke() function. * * @return void */ public function testInvoke() { $request = Request::createFromEnvironment(Environment::mock()); $this->middleware->__invoke( $request->withHeader('Accept-Language', 'fr-FR'), new Response(), [$this, 'nothing'] ); } /** * Test the __invoke() function withot the Accept-Language header. * * @return void */ public function testInvokeWithoutHeader() { $request = Request::createFromEnvironment(Environment::mock()); $this->middleware->__invoke( $request->withoutHeader('Accept-Language'), new Response(), [$this, 'nothing'] ); } /** * Test that the environment is correctly set up. * * @return void */ public function testEnv() { $this->markTestIncomplete('We need to find a way to reliably test LC_ALL and LANG values'); } }