More tidying.
[yaffs-website] / vendor / symfony / translation / Tests / Writer / TranslationWriterTest.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\Writer;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Translation\Dumper\DumperInterface;
16 use Symfony\Component\Translation\MessageCatalogue;
17 use Symfony\Component\Translation\Writer\TranslationWriter;
18
19 class TranslationWriterTest extends TestCase
20 {
21     public function testWriteTranslations()
22     {
23         $dumper = $this->getMockBuilder('Symfony\Component\Translation\Dumper\DumperInterface')->getMock();
24         $dumper
25             ->expects($this->once())
26             ->method('dump');
27
28         $writer = new TranslationWriter();
29         $writer->addDumper('test', $dumper);
30         $writer->writeTranslations(new MessageCatalogue(array()), 'test');
31     }
32
33     public function testDisableBackup()
34     {
35         $nonBackupDumper = new NonBackupDumper();
36         $backupDumper = new BackupDumper();
37
38         $writer = new TranslationWriter();
39         $writer->addDumper('non_backup', $nonBackupDumper);
40         $writer->addDumper('backup', $backupDumper);
41         $writer->disableBackup();
42
43         $this->assertFalse($backupDumper->backup, 'backup can be disabled if setBackup() method does exist');
44     }
45 }
46
47 class NonBackupDumper implements DumperInterface
48 {
49     public function dump(MessageCatalogue $messages, $options = array())
50     {
51     }
52 }
53
54 class BackupDumper implements DumperInterface
55 {
56     public $backup = true;
57
58     public function dump(MessageCatalogue $messages, $options = array())
59     {
60     }
61
62     public function setBackup($backup)
63     {
64         $this->backup = $backup;
65     }
66 }