4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Tests\Writer;
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;
19 class TranslationWriterTest extends TestCase
21 public function testWriteTranslations()
23 $dumper = $this->getMockBuilder('Symfony\Component\Translation\Dumper\DumperInterface')->getMock();
25 ->expects($this->once())
28 $writer = new TranslationWriter();
29 $writer->addDumper('test', $dumper);
30 $writer->writeTranslations(new MessageCatalogue(array()), 'test');
33 public function testDisableBackup()
35 $nonBackupDumper = new NonBackupDumper();
36 $backupDumper = new BackupDumper();
38 $writer = new TranslationWriter();
39 $writer->addDumper('non_backup', $nonBackupDumper);
40 $writer->addDumper('backup', $backupDumper);
41 $writer->disableBackup();
43 $this->assertFalse($backupDumper->backup, 'backup can be disabled if setBackup() method does exist');
47 class NonBackupDumper implements DumperInterface
49 public function dump(MessageCatalogue $messages, $options = array())
54 class BackupDumper implements DumperInterface
56 public $backup = true;
58 public function dump(MessageCatalogue $messages, $options = array())
62 public function setBackup($backup)
64 $this->backup = $backup;