Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 1 | <?php |
2 | |||||
3 | /* | ||||
4 | * Licensed to the Apache Software Foundation (ASF) under one | ||||
5 | * or more contributor license agreements. See the NOTICE file | ||||
6 | * distributed with this work for additional information | ||||
7 | * regarding copyright ownership. The ASF licenses this file | ||||
8 | * to you under the Apache License, Version 2.0 (the | ||||
9 | * "License"); you may not use this file except in compliance | ||||
10 | * with the License. You may obtain a copy of the License at | ||||
11 | * | ||||
12 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
13 | * | ||||
14 | * Unless required by applicable law or agreed to in writing, | ||||
15 | * software distributed under the License is distributed on an | ||||
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
17 | * KIND, either express or implied. See the License for the | ||||
18 | * specific language governing permissions and limitations | ||||
19 | * under the License. | ||||
20 | * | ||||
21 | * @package thrift.test | ||||
22 | */ | ||||
23 | |||||
24 | namespace Test\Thrift; | ||||
25 | |||||
26 | use ThriftTest\Xtruct; | ||||
27 | use ThriftTest\Xtruct2; | ||||
28 | use ThriftTest\Numberz; | ||||
29 | use ThriftTest\Insanity; | ||||
30 | |||||
31 | class Fixtures | ||||
32 | { | ||||
33 | public static $testArgs = array(); | ||||
34 | |||||
35 | public static function populateTestArgs() | ||||
36 | { | ||||
37 | self::$testArgs['testString1'] = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語"; | ||||
38 | |||||
39 | self::$testArgs['testString2'] = | ||||
40 | "quote: \\\" backslash:" . | ||||
41 | " forwardslash-escaped: \\/ " . | ||||
42 | " backspace: \b formfeed: \f newline: \n return: \r tab: " . | ||||
43 | " now-all-of-them-together: \"\\\/\b\n\r\t" . | ||||
44 | " now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><"; | ||||
45 | |||||
46 | self::$testArgs['testString3'] = | ||||
47 | "string that ends in double-backslash \\\\"; | ||||
48 | |||||
Phongphan Phuttha | 90ea4f6 | 2015-10-30 00:00:10 +0700 | [diff] [blame^] | 49 | self::$testArgs['testUnicodeStringWithNonBMP'] = |
50 | "สวัสดี/𝒯"; | ||||
51 | |||||
Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 52 | self::$testArgs['testDouble'] = 3.1415926535898; |
53 | |||||
Jens Geyer | 8bcfdd9 | 2014-12-14 03:14:26 +0100 | [diff] [blame] | 54 | // TODO: add testBinary() call |
55 | |||||
Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 56 | self::$testArgs['testByte'] = 0x01; |
57 | |||||
58 | self::$testArgs['testI32'] = pow( 2, 30 ); | ||||
59 | |||||
Roger Thomas | 6fb5923 | 2014-11-04 10:09:23 +0000 | [diff] [blame] | 60 | if (PHP_INT_SIZE == 8) { |
Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 61 | self::$testArgs['testI64'] = pow( 2, 60 ); |
Roger Thomas | 6fb5923 | 2014-11-04 10:09:23 +0000 | [diff] [blame] | 62 | } else { |
Roger Meier | 21c0a85 | 2012-09-05 19:47:14 +0000 | [diff] [blame] | 63 | self::$testArgs['testI64'] = "1152921504606847000"; |
64 | } | ||||
65 | |||||
66 | self::$testArgs['testStruct'] = | ||||
67 | new Xtruct( | ||||
68 | array( | ||||
69 | 'string_thing' => 'worked', | ||||
70 | 'byte_thing' => 0x01, | ||||
71 | 'i32_thing' => pow( 2, 30 ), | ||||
72 | 'i64_thing' => self::$testArgs['testI64'] | ||||
73 | ) | ||||
74 | ); | ||||
75 | |||||
76 | self::$testArgs['testNestNested'] = | ||||
77 | new Xtruct( | ||||
78 | array( | ||||
79 | 'string_thing' => 'worked', | ||||
80 | 'byte_thing' => 0x01, | ||||
81 | 'i32_thing' => pow( 2, 30 ), | ||||
82 | 'i64_thing' => self::$testArgs['testI64'] | ||||
83 | ) | ||||
84 | ); | ||||
85 | |||||
86 | self::$testArgs['testNest'] = | ||||
87 | new Xtruct2( | ||||
88 | array( | ||||
89 | 'byte_thing' => 0x01, | ||||
90 | 'struct_thing' => self::$testArgs['testNestNested'], | ||||
91 | 'i32_thing' => pow( 2, 15 ) | ||||
92 | ) | ||||
93 | ); | ||||
94 | |||||
95 | self::$testArgs['testMap'] = | ||||
96 | array( | ||||
97 | 7 => 77, | ||||
98 | 8 => 88, | ||||
99 | 9 => 99 | ||||
100 | ); | ||||
101 | |||||
102 | self::$testArgs['testStringMap'] = | ||||
103 | array( | ||||
104 | "a" => "123", | ||||
105 | "a b" => "with spaces ", | ||||
106 | "same" => "same", | ||||
107 | "0" => "numeric key", | ||||
108 | "longValue" => self::$testArgs['testString1'], | ||||
109 | self::$testArgs['testString1'] => "long key" | ||||
110 | ); | ||||
111 | |||||
112 | self::$testArgs['testSet'] = array( 1 => true, 5 => true, 6 => true ); | ||||
113 | |||||
114 | self::$testArgs['testList'] = array( 1, 2, 3 ); | ||||
115 | |||||
116 | self::$testArgs['testEnum'] = Numberz::ONE; | ||||
117 | |||||
118 | self::$testArgs['testTypedef'] = 69; | ||||
119 | |||||
120 | self::$testArgs['testMapMapExpectedResult'] = | ||||
121 | array( | ||||
122 | 4 => array( | ||||
123 | 1 => 1, | ||||
124 | 2 => 2, | ||||
125 | 3 => 3, | ||||
126 | 4 => 4, | ||||
127 | ), | ||||
128 | -4 => array( | ||||
129 | -4 => -4, | ||||
130 | -3 => -3, | ||||
131 | -2 => -2, | ||||
132 | -1 => -1 | ||||
133 | ) | ||||
134 | ); | ||||
135 | |||||
136 | // testInsanity ... takes a few steps to set up! | ||||
137 | |||||
138 | $xtruct1 = | ||||
139 | new Xtruct( | ||||
140 | array( | ||||
141 | 'string_thing' => 'Goodbye4', | ||||
142 | 'byte_thing' => 4, | ||||
143 | 'i32_thing' => 4, | ||||
144 | 'i64_thing' => 4 | ||||
145 | ) | ||||
146 | ); | ||||
147 | |||||
148 | $xtruct2 = | ||||
149 | new Xtruct( | ||||
150 | array( | ||||
151 | 'string_thing' => 'Hello2', | ||||
152 | 'byte_thing' =>2, | ||||
153 | 'i32_thing' => 2, | ||||
154 | 'i64_thing' => 2 | ||||
155 | ) | ||||
156 | ); | ||||
157 | |||||
158 | $userMap = | ||||
159 | array( | ||||
160 | Numberz::FIVE => 5, | ||||
161 | Numberz::EIGHT => 8 | ||||
162 | ); | ||||
163 | |||||
164 | $insanity2 = | ||||
165 | new Insanity( | ||||
166 | array( | ||||
167 | 'userMap' => $userMap, | ||||
168 | 'xtructs' => array($xtruct1,$xtruct2) | ||||
169 | ) | ||||
170 | ); | ||||
171 | |||||
172 | $insanity3 = $insanity2; | ||||
173 | |||||
174 | $insanity6 = | ||||
175 | new Insanity( | ||||
176 | array( | ||||
177 | 'userMap' => null, | ||||
178 | 'xtructs' => null | ||||
179 | ) | ||||
180 | ); | ||||
181 | |||||
182 | self::$testArgs['testInsanityExpectedResult'] = | ||||
183 | array( | ||||
184 | "1" => array( | ||||
185 | Numberz::TWO => $insanity2, | ||||
186 | Numberz::THREE => $insanity3 | ||||
187 | ), | ||||
188 | "2" => array( | ||||
189 | Numberz::SIX => $insanity6 | ||||
190 | ) | ||||
191 | ); | ||||
192 | |||||
193 | } | ||||
194 | } |