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,124 +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;
13
-
14
-use PHPUnit\Framework\TestCase;
15
-use Symfony\Component\Translation\PluralizationRules;
16
-
17
-/**
18
- * Test should cover all languages mentioned on http://translate.sourceforge.net/wiki/l10n/pluralforms
19
- * and Plural forms mentioned on http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms.
20
- *
21
- * See also https://developer.mozilla.org/en/Localization_and_Plurals which mentions 15 rules having a maximum of 6 forms.
22
- * The mozilla code is also interesting to check for.
23
- *
24
- * As mentioned by chx http://drupal.org/node/1273968 we can cover all by testing number from 0 to 199
25
- *
26
- * The goal to cover all languages is to far fetched so this test case is smaller.
27
- *
28
- * @author Clemens Tolboom clemens@build2be.nl
29
- *
30
- * @group legacy
31
- */
32
-class PluralizationRulesTest extends TestCase
33
-{
34
-    /**
35
-     * We test failed langcode here.
36
-     *
37
-     * TODO: The languages mentioned in the data provide need to get fixed somehow within PluralizationRules.
38
-     *
39
-     * @dataProvider failingLangcodes
40
-     */
41
-    public function testFailedLangcodes($nplural, $langCodes)
42
-    {
43
-        $matrix = $this->generateTestData($langCodes);
44
-        $this->validateMatrix($nplural, $matrix, false);
45
-    }
46
-
47
-    /**
48
-     * @dataProvider successLangcodes
49
-     */
50
-    public function testLangcodes($nplural, $langCodes)
51
-    {
52
-        $matrix = $this->generateTestData($langCodes);
53
-        $this->validateMatrix($nplural, $matrix);
54
-    }
55
-
56
-    /**
57
-     * This array should contain all currently known langcodes.
58
-     *
59
-     * As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
60
-     *
61
-     * @return array
62
-     */
63
-    public function successLangcodes()
64
-    {
65
-        return [
66
-            ['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
67
-            ['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']],
68
-            ['3', ['be', 'bs', 'cs', 'hr']],
69
-            ['4', ['cy', 'mt', 'sl']],
70
-            ['6', ['ar']],
71
-        ];
72
-    }
73
-
74
-    /**
75
-     * This array should be at least empty within the near future.
76
-     *
77
-     * This both depends on a complete list trying to add above as understanding
78
-     * the plural rules of the current failing languages.
79
-     *
80
-     * @return array with nplural together with langcodes
81
-     */
82
-    public function failingLangcodes()
83
-    {
84
-        return [
85
-            ['1', ['fa']],
86
-            ['2', ['jbo']],
87
-            ['3', ['cbs']],
88
-            ['4', ['gd', 'kw']],
89
-            ['5', ['ga']],
90
-        ];
91
-    }
92
-
93
-    /**
94
-     * We validate only on the plural coverage. Thus the real rules is not tested.
95
-     *
96
-     * @param string $nplural       Plural expected
97
-     * @param array  $matrix        Containing langcodes and their plural index values
98
-     * @param bool   $expectSuccess
99
-     */
100
-    protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
101
-    {
102
-        foreach ($matrix as $langCode => $data) {
103
-            $indexes = array_flip($data);
104
-            if ($expectSuccess) {
105
-                $this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
106
-            } else {
107
-                $this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
108
-            }
109
-        }
110
-    }
111
-
112
-    protected function generateTestData($langCodes)
113
-    {
114
-        $matrix = [];
115
-        foreach ($langCodes as $langCode) {
116
-            for ($count = 0; $count < 200; ++$count) {
117
-                $plural = PluralizationRules::get($count, $langCode);
118
-                $matrix[$langCode][$count] = $plural;
119
-            }
120
-        }
121
-
122
-        return $matrix;
123
-    }
124
-}
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,124 @@
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\PluralizationRules;
16
+
17
+/**
18
+ * Test should cover all languages mentioned on http://translate.sourceforge.net/wiki/l10n/pluralforms
19
+ * and Plural forms mentioned on http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms.
20
+ *
21
+ * See also https://developer.mozilla.org/en/Localization_and_Plurals which mentions 15 rules having a maximum of 6 forms.
22
+ * The mozilla code is also interesting to check for.
23
+ *
24
+ * As mentioned by chx http://drupal.org/node/1273968 we can cover all by testing number from 0 to 199
25
+ *
26
+ * The goal to cover all languages is to far fetched so this test case is smaller.
27
+ *
28
+ * @author Clemens Tolboom clemens@build2be.nl
29
+ *
30
+ * @group legacy
31
+ */
32
+class PluralizationRulesTest extends TestCase
33
+{
34
+    /**
35
+     * We test failed langcode here.
36
+     *
37
+     * TODO: The languages mentioned in the data provide need to get fixed somehow within PluralizationRules.
38
+     *
39
+     * @dataProvider failingLangcodes
40
+     */
41
+    public function testFailedLangcodes($nplural, $langCodes)
42
+    {
43
+        $matrix = $this->generateTestData($langCodes);
44
+        $this->validateMatrix($nplural, $matrix, false);
45
+    }
46
+
47
+    /**
48
+     * @dataProvider successLangcodes
49
+     */
50
+    public function testLangcodes($nplural, $langCodes)
51
+    {
52
+        $matrix = $this->generateTestData($langCodes);
53
+        $this->validateMatrix($nplural, $matrix);
54
+    }
55
+
56
+    /**
57
+     * This array should contain all currently known langcodes.
58
+     *
59
+     * As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
60
+     *
61
+     * @return array
62
+     */
63
+    public function successLangcodes()
64
+    {
65
+        return [
66
+            ['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
67
+            ['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']],
68
+            ['3', ['be', 'bs', 'cs', 'hr']],
69
+            ['4', ['cy', 'mt', 'sl']],
70
+            ['6', ['ar']],
71
+        ];
72
+    }
73
+
74
+    /**
75
+     * This array should be at least empty within the near future.
76
+     *
77
+     * This both depends on a complete list trying to add above as understanding
78
+     * the plural rules of the current failing languages.
79
+     *
80
+     * @return array with nplural together with langcodes
81
+     */
82
+    public function failingLangcodes()
83
+    {
84
+        return [
85
+            ['1', ['fa']],
86
+            ['2', ['jbo']],
87
+            ['3', ['cbs']],
88
+            ['4', ['gd', 'kw']],
89
+            ['5', ['ga']],
90
+        ];
91
+    }
92
+
93
+    /**
94
+     * We validate only on the plural coverage. Thus the real rules is not tested.
95
+     *
96
+     * @param string $nplural       Plural expected
97
+     * @param array  $matrix        Containing langcodes and their plural index values
98
+     * @param bool   $expectSuccess
99
+     */
100
+    protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
101
+    {
102
+        foreach ($matrix as $langCode => $data) {
103
+            $indexes = array_flip($data);
104
+            if ($expectSuccess) {
105
+                $this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
106
+            } else {
107
+                $this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
108
+            }
109
+        }
110
+    }
111
+
112
+    protected function generateTestData($langCodes)
113
+    {
114
+        $matrix = [];
115
+        foreach ($langCodes as $langCode) {
116
+            for ($count = 0; $count < 200; ++$count) {
117
+                $plural = PluralizationRules::get($count, $langCode);
118
+                $matrix[$langCode][$count] = $plural;
119
+            }
120
+        }
121
+
122
+        return $matrix;
123
+    }
124
+}