1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,69 +0,0 @@ |
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 testWrite() |
|
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->write(new MessageCatalogue('en'), 'test'); |
|
31 |
- } |
|
32 |
- |
|
33 |
- /** |
|
34 |
- * @group legacy |
|
35 |
- */ |
|
36 |
- public function testDisableBackup() |
|
37 |
- { |
|
38 |
- $nonBackupDumper = new NonBackupDumper(); |
|
39 |
- $backupDumper = new BackupDumper(); |
|
40 |
- |
|
41 |
- $writer = new TranslationWriter(); |
|
42 |
- $writer->addDumper('non_backup', $nonBackupDumper); |
|
43 |
- $writer->addDumper('backup', $backupDumper); |
|
44 |
- $writer->disableBackup(); |
|
45 |
- |
|
46 |
- $this->assertFalse($backupDumper->backup, 'backup can be disabled if setBackup() method does exist'); |
|
47 |
- } |
|
48 |
-} |
|
49 |
- |
|
50 |
-class NonBackupDumper implements DumperInterface |
|
51 |
-{ |
|
52 |
- public function dump(MessageCatalogue $messages, $options = []) |
|
53 |
- { |
|
54 |
- } |
|
55 |
-} |
|
56 |
- |
|
57 |
-class BackupDumper implements DumperInterface |
|
58 |
-{ |
|
59 |
- public $backup = true; |
|
60 |
- |
|
61 |
- public function dump(MessageCatalogue $messages, $options = []) |
|
62 |
- { |
|
63 |
- } |
|
64 |
- |
|
65 |
- public function setBackup($backup) |
|
66 |
- { |
|
67 |
- $this->backup = $backup; |
|
68 |
- } |
|
69 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,69 @@ |
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 testWrite() |
|
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->write(new MessageCatalogue('en'), 'test'); |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ /** |
|
34 |
+ * @group legacy |
|
35 |
+ */ |
|
36 |
+ public function testDisableBackup() |
|
37 |
+ { |
|
38 |
+ $nonBackupDumper = new NonBackupDumper(); |
|
39 |
+ $backupDumper = new BackupDumper(); |
|
40 |
+ |
|
41 |
+ $writer = new TranslationWriter(); |
|
42 |
+ $writer->addDumper('non_backup', $nonBackupDumper); |
|
43 |
+ $writer->addDumper('backup', $backupDumper); |
|
44 |
+ $writer->disableBackup(); |
|
45 |
+ |
|
46 |
+ $this->assertFalse($backupDumper->backup, 'backup can be disabled if setBackup() method does exist'); |
|
47 |
+ } |
|
48 |
+} |
|
49 |
+ |
|
50 |
+class NonBackupDumper implements DumperInterface |
|
51 |
+{ |
|
52 |
+ public function dump(MessageCatalogue $messages, $options = []) |
|
53 |
+ { |
|
54 |
+ } |
|
55 |
+} |
|
56 |
+ |
|
57 |
+class BackupDumper implements DumperInterface |
|
58 |
+{ |
|
59 |
+ public $backup = true; |
|
60 |
+ |
|
61 |
+ public function dump(MessageCatalogue $messages, $options = []) |
|
62 |
+ { |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ public function setBackup($backup) |
|
66 |
+ { |
|
67 |
+ $this->backup = $backup; |
|
68 |
+ } |
|
69 |
+} |