Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,130 +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\Dumper;
13
-
14
-use PHPUnit\Framework\TestCase;
15
-use Symfony\Component\Translation\Dumper\XliffFileDumper;
16
-use Symfony\Component\Translation\MessageCatalogue;
17
-
18
-class XliffFileDumperTest extends TestCase
19
-{
20
-    public function testFormatCatalogue()
21
-    {
22
-        $catalogue = new MessageCatalogue('en_US');
23
-        $catalogue->add([
24
-            'foo' => 'bar',
25
-            'key' => '',
26
-            'key.with.cdata' => '<source> & <target>',
27
-        ]);
28
-        $catalogue->setMetadata('foo', ['notes' => [['priority' => 1, 'from' => 'bar', 'content' => 'baz']]]);
29
-        $catalogue->setMetadata('key', ['notes' => [['content' => 'baz'], ['content' => 'qux']]]);
30
-
31
-        $dumper = new XliffFileDumper();
32
-
33
-        $this->assertStringEqualsFile(
34
-            __DIR__.'/../fixtures/resources-clean.xlf',
35
-            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR'])
36
-        );
37
-    }
38
-
39
-    public function testFormatCatalogueXliff2()
40
-    {
41
-        $catalogue = new MessageCatalogue('en_US');
42
-        $catalogue->add([
43
-            'foo' => 'bar',
44
-            'key' => '',
45
-            'key.with.cdata' => '<source> & <target>',
46
-        ]);
47
-        $catalogue->setMetadata('key', ['target-attributes' => ['order' => 1]]);
48
-
49
-        $dumper = new XliffFileDumper();
50
-
51
-        $this->assertStringEqualsFile(
52
-            __DIR__.'/../fixtures/resources-2.0-clean.xlf',
53
-            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
54
-        );
55
-    }
56
-
57
-    public function testFormatIcuCatalogueXliff2()
58
-    {
59
-        $catalogue = new MessageCatalogue('en_US');
60
-        $catalogue->add([
61
-            'foo' => 'bar',
62
-        ], 'messages'.MessageCatalogue::INTL_DOMAIN_SUFFIX);
63
-
64
-        $dumper = new XliffFileDumper();
65
-
66
-        $this->assertStringEqualsFile(
67
-            __DIR__.'/../fixtures/resources-2.0+intl-icu.xlf',
68
-            $dumper->formatCatalogue($catalogue, 'messages'.MessageCatalogue::INTL_DOMAIN_SUFFIX, ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
69
-        );
70
-    }
71
-
72
-    public function testFormatCatalogueWithCustomToolInfo()
73
-    {
74
-        $options = [
75
-            'default_locale' => 'en_US',
76
-            'tool_info' => ['tool-id' => 'foo', 'tool-name' => 'foo', 'tool-version' => '0.0', 'tool-company' => 'Foo'],
77
-        ];
78
-
79
-        $catalogue = new MessageCatalogue('en_US');
80
-        $catalogue->add(['foo' => 'bar']);
81
-
82
-        $dumper = new XliffFileDumper();
83
-
84
-        $this->assertStringEqualsFile(
85
-            __DIR__.'/../fixtures/resources-tool-info.xlf',
86
-            $dumper->formatCatalogue($catalogue, 'messages', $options)
87
-        );
88
-    }
89
-
90
-    public function testFormatCatalogueWithTargetAttributesMetadata()
91
-    {
92
-        $catalogue = new MessageCatalogue('en_US');
93
-        $catalogue->add([
94
-            'foo' => 'bar',
95
-        ]);
96
-        $catalogue->setMetadata('foo', ['target-attributes' => ['state' => 'needs-translation']]);
97
-
98
-        $dumper = new XliffFileDumper();
99
-
100
-        $this->assertStringEqualsFile(
101
-            __DIR__.'/../fixtures/resources-target-attributes.xlf',
102
-            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR'])
103
-        );
104
-    }
105
-
106
-    public function testFormatCatalogueWithNotesMetadata()
107
-    {
108
-        $catalogue = new MessageCatalogue('en_US');
109
-        $catalogue->add([
110
-            'foo' => 'bar',
111
-            'baz' => 'biz',
112
-        ]);
113
-        $catalogue->setMetadata('foo', ['notes' => [
114
-            ['category' => 'state', 'content' => 'new'],
115
-            ['category' => 'approved', 'content' => 'true'],
116
-            ['category' => 'section', 'content' => 'user login', 'priority' => '1'],
117
-        ]]);
118
-        $catalogue->setMetadata('baz', ['notes' => [
119
-            ['id' => 'x', 'content' => 'x_content'],
120
-            ['appliesTo' => 'target', 'category' => 'quality', 'content' => 'Fuzzy'],
121
-        ]]);
122
-
123
-        $dumper = new XliffFileDumper();
124
-
125
-        $this->assertStringEqualsFile(
126
-            __DIR__.'/../fixtures/resources-notes-meta.xlf',
127
-            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
128
-        );
129
-    }
130
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,130 @@
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\Dumper;
13
+
14
+use PHPUnit\Framework\TestCase;
15
+use Symfony\Component\Translation\Dumper\XliffFileDumper;
16
+use Symfony\Component\Translation\MessageCatalogue;
17
+
18
+class XliffFileDumperTest extends TestCase
19
+{
20
+    public function testFormatCatalogue()
21
+    {
22
+        $catalogue = new MessageCatalogue('en_US');
23
+        $catalogue->add([
24
+            'foo' => 'bar',
25
+            'key' => '',
26
+            'key.with.cdata' => '<source> & <target>',
27
+        ]);
28
+        $catalogue->setMetadata('foo', ['notes' => [['priority' => 1, 'from' => 'bar', 'content' => 'baz']]]);
29
+        $catalogue->setMetadata('key', ['notes' => [['content' => 'baz'], ['content' => 'qux']]]);
30
+
31
+        $dumper = new XliffFileDumper();
32
+
33
+        $this->assertStringEqualsFile(
34
+            __DIR__.'/../fixtures/resources-clean.xlf',
35
+            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR'])
36
+        );
37
+    }
38
+
39
+    public function testFormatCatalogueXliff2()
40
+    {
41
+        $catalogue = new MessageCatalogue('en_US');
42
+        $catalogue->add([
43
+            'foo' => 'bar',
44
+            'key' => '',
45
+            'key.with.cdata' => '<source> & <target>',
46
+        ]);
47
+        $catalogue->setMetadata('key', ['target-attributes' => ['order' => 1]]);
48
+
49
+        $dumper = new XliffFileDumper();
50
+
51
+        $this->assertStringEqualsFile(
52
+            __DIR__.'/../fixtures/resources-2.0-clean.xlf',
53
+            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
54
+        );
55
+    }
56
+
57
+    public function testFormatIcuCatalogueXliff2()
58
+    {
59
+        $catalogue = new MessageCatalogue('en_US');
60
+        $catalogue->add([
61
+            'foo' => 'bar',
62
+        ], 'messages'.MessageCatalogue::INTL_DOMAIN_SUFFIX);
63
+
64
+        $dumper = new XliffFileDumper();
65
+
66
+        $this->assertStringEqualsFile(
67
+            __DIR__.'/../fixtures/resources-2.0+intl-icu.xlf',
68
+            $dumper->formatCatalogue($catalogue, 'messages'.MessageCatalogue::INTL_DOMAIN_SUFFIX, ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
69
+        );
70
+    }
71
+
72
+    public function testFormatCatalogueWithCustomToolInfo()
73
+    {
74
+        $options = [
75
+            'default_locale' => 'en_US',
76
+            'tool_info' => ['tool-id' => 'foo', 'tool-name' => 'foo', 'tool-version' => '0.0', 'tool-company' => 'Foo'],
77
+        ];
78
+
79
+        $catalogue = new MessageCatalogue('en_US');
80
+        $catalogue->add(['foo' => 'bar']);
81
+
82
+        $dumper = new XliffFileDumper();
83
+
84
+        $this->assertStringEqualsFile(
85
+            __DIR__.'/../fixtures/resources-tool-info.xlf',
86
+            $dumper->formatCatalogue($catalogue, 'messages', $options)
87
+        );
88
+    }
89
+
90
+    public function testFormatCatalogueWithTargetAttributesMetadata()
91
+    {
92
+        $catalogue = new MessageCatalogue('en_US');
93
+        $catalogue->add([
94
+            'foo' => 'bar',
95
+        ]);
96
+        $catalogue->setMetadata('foo', ['target-attributes' => ['state' => 'needs-translation']]);
97
+
98
+        $dumper = new XliffFileDumper();
99
+
100
+        $this->assertStringEqualsFile(
101
+            __DIR__.'/../fixtures/resources-target-attributes.xlf',
102
+            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR'])
103
+        );
104
+    }
105
+
106
+    public function testFormatCatalogueWithNotesMetadata()
107
+    {
108
+        $catalogue = new MessageCatalogue('en_US');
109
+        $catalogue->add([
110
+            'foo' => 'bar',
111
+            'baz' => 'biz',
112
+        ]);
113
+        $catalogue->setMetadata('foo', ['notes' => [
114
+            ['category' => 'state', 'content' => 'new'],
115
+            ['category' => 'approved', 'content' => 'true'],
116
+            ['category' => 'section', 'content' => 'user login', 'priority' => '1'],
117
+        ]]);
118
+        $catalogue->setMetadata('baz', ['notes' => [
119
+            ['id' => 'x', 'content' => 'x_content'],
120
+            ['appliesTo' => 'target', 'category' => 'quality', 'content' => 'Fuzzy'],
121
+        ]]);
122
+
123
+        $dumper = new XliffFileDumper();
124
+
125
+        $this->assertStringEqualsFile(
126
+            __DIR__.'/../fixtures/resources-notes-meta.xlf',
127
+            $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
128
+        );
129
+    }
130
+}