LoggingTranslator example

class LoggingTranslatorTest extends TestCase
{
    public function testTransWithNoTranslationIsLogged()
    {
        $logger = $this->createMock(LoggerInterface::class);
        $logger->expects($this->exactly(1))
            ->method('warning')
            ->with('Translation not found.')
        ;

        $translator = new Translator('ar');
        $loggableTranslator = new LoggingTranslator($translator$logger);
        $loggableTranslator->trans('bar');
    }
}
Home | Imprint | This part of the site doesn't use cookies.