Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / translation / Tests / LoggingTranslatorTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Translation\Tests;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Translation\Loader\ArrayLoader;
16 use Symfony\Component\Translation\LoggingTranslator;
17 use Symfony\Component\Translation\Translator;
18
19 class LoggingTranslatorTest extends TestCase
20 {
21     public function testTransWithNoTranslationIsLogged()
22     {
23         $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
24         $logger->expects($this->exactly(2))
25             ->method('warning')
26             ->with('Translation not found.')
27         ;
28
29         $translator = new Translator('ar');
30         $loggableTranslator = new LoggingTranslator($translator, $logger);
31         $loggableTranslator->transChoice('some_message2', 10, array('%count%' => 10));
32         $loggableTranslator->trans('bar');
33     }
34
35     public function testTransChoiceFallbackIsLogged()
36     {
37         $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
38         $logger->expects($this->once())
39             ->method('debug')
40             ->with('Translation use fallback catalogue.')
41         ;
42
43         $translator = new Translator('ar');
44         $translator->setFallbackLocales(array('en'));
45         $translator->addLoader('array', new ArrayLoader());
46         $translator->addResource('array', array('some_message2' => 'one thing|%count% things'), 'en');
47         $loggableTranslator = new LoggingTranslator($translator, $logger);
48         $loggableTranslator->transChoice('some_message2', 10, array('%count%' => 10));
49     }
50 }