blob: fd57d831c5e92331959aebe2c630b9f594e1b62b [file] [log] [blame]
Roger Meier21c0a852012-09-05 19:47:14 +00001<?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
24namespace Test\Thrift;
25
26use ThriftTest\Xtruct;
27use ThriftTest\Xtruct2;
28use ThriftTest\Numberz;
29use ThriftTest\Insanity;
30
31class Fixtures
32{
Robert Lu12f124c2018-01-25 23:19:41 +080033 public static $bufsize = 8192; //big enough to read biggest serialized Fixture arg.
34 public static $testArgs = array();
Roger Meier21c0a852012-09-05 19:47:14 +000035
Robert Lu12f124c2018-01-25 23:19:41 +080036 public static function populateTestArgs()
37 {
38 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ú, 粵語";
Roger Meier21c0a852012-09-05 19:47:14 +000039
Robert Lu12f124c2018-01-25 23:19:41 +080040 self::$testArgs['testString2'] =
41 "quote: \\\" backslash:" .
42 " forwardslash-escaped: \\/ " .
43 " backspace: \b formfeed: \f newline: \n return: \r tab: " .
44 " now-all-of-them-together: \"\\\/\b\n\r\t" .
45 " now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><";
Roger Meier21c0a852012-09-05 19:47:14 +000046
Robert Lu12f124c2018-01-25 23:19:41 +080047 self::$testArgs['testString3'] =
48 "string that ends in double-backslash \\\\";
Roger Meier21c0a852012-09-05 19:47:14 +000049
Robert Lu12f124c2018-01-25 23:19:41 +080050 self::$testArgs['testUnicodeStringWithNonBMP'] =
51 "สวัสดี/𝒯";
Phongphan Phuttha90ea4f62015-10-30 00:00:10 +070052
Robert Lu12f124c2018-01-25 23:19:41 +080053 self::$testArgs['testDouble'] = 3.1415926535898;
Roger Meier21c0a852012-09-05 19:47:14 +000054
Robert Lu12f124c2018-01-25 23:19:41 +080055 // TODO: add testBinary() call
Roger Meier21c0a852012-09-05 19:47:14 +000056
Robert Lu12f124c2018-01-25 23:19:41 +080057 self::$testArgs['testByte'] = 0x01;
Roger Meier21c0a852012-09-05 19:47:14 +000058
Robert Lu12f124c2018-01-25 23:19:41 +080059 self::$testArgs['testI32'] = pow(2, 30);
60
61 if (PHP_INT_SIZE == 8) {
62 self::$testArgs['testI64'] = pow(2, 60);
63 } else {
64 self::$testArgs['testI64'] = "1152921504606847000";
65 }
66
67 self::$testArgs['testStruct'] =
68 new Xtruct(
Jens Geyer9ea48f32019-11-02 12:20:29 +010069 array(
Robert Lu12f124c2018-01-25 23:19:41 +080070 'string_thing' => 'worked',
71 'byte_thing' => 0x01,
72 'i32_thing' => pow(2, 30),
73 'i64_thing' => self::$testArgs['testI64']
74 )
Jens Geyer9ea48f32019-11-02 12:20:29 +010075 );
Robert Lu12f124c2018-01-25 23:19:41 +080076
77 self::$testArgs['testNestNested'] =
78 new Xtruct(
Jens Geyer9ea48f32019-11-02 12:20:29 +010079 array(
Robert Lu12f124c2018-01-25 23:19:41 +080080 'string_thing' => 'worked',
81 'byte_thing' => 0x01,
82 'i32_thing' => pow(2, 30),
83 'i64_thing' => self::$testArgs['testI64']
84 )
Jens Geyer9ea48f32019-11-02 12:20:29 +010085 );
Robert Lu12f124c2018-01-25 23:19:41 +080086
87 self::$testArgs['testNest'] =
88 new Xtruct2(
Jens Geyer9ea48f32019-11-02 12:20:29 +010089 array(
Robert Lu12f124c2018-01-25 23:19:41 +080090 'byte_thing' => 0x01,
91 'struct_thing' => self::$testArgs['testNestNested'],
92 'i32_thing' => pow(2, 15)
93 )
Jens Geyer9ea48f32019-11-02 12:20:29 +010094 );
Robert Lu12f124c2018-01-25 23:19:41 +080095
96 self::$testArgs['testMap'] =
97 array(
98 7 => 77,
99 8 => 88,
100 9 => 99
101 );
102
103 self::$testArgs['testStringMap'] =
104 array(
105 "a" => "123",
106 "a b" => "with spaces ",
107 "same" => "same",
108 "0" => "numeric key",
109 "longValue" => self::$testArgs['testString1'],
110 self::$testArgs['testString1'] => "long key"
111 );
112
113 self::$testArgs['testSet'] = array(1 => true, 5 => true, 6 => true);
114
115 self::$testArgs['testList'] = array(1, 2, 3);
116
117 self::$testArgs['testEnum'] = Numberz::ONE;
118
119 self::$testArgs['testTypedef'] = 69;
120
121 self::$testArgs['testMapMapExpectedResult'] =
122 array(
123 4 => array(
124 1 => 1,
125 2 => 2,
126 3 => 3,
127 4 => 4,
128 ),
129 -4 => array(
130 -4 => -4,
131 -3 => -3,
132 -2 => -2,
133 -1 => -1
134 )
135 );
136
137 // testInsanity ... takes a few steps to set up!
138
139 $xtruct1 =
140 new Xtruct(
Jens Geyer9ea48f32019-11-02 12:20:29 +0100141 array(
Robert Lu12f124c2018-01-25 23:19:41 +0800142 'string_thing' => 'Goodbye4',
143 'byte_thing' => 4,
144 'i32_thing' => 4,
145 'i64_thing' => 4
146 )
Jens Geyer9ea48f32019-11-02 12:20:29 +0100147 );
Robert Lu12f124c2018-01-25 23:19:41 +0800148
149 $xtruct2 =
150 new Xtruct(
Jens Geyer9ea48f32019-11-02 12:20:29 +0100151 array(
Robert Lu12f124c2018-01-25 23:19:41 +0800152 'string_thing' => 'Hello2',
153 'byte_thing' => 2,
154 'i32_thing' => 2,
155 'i64_thing' => 2
156 )
Jens Geyer9ea48f32019-11-02 12:20:29 +0100157 );
Robert Lu12f124c2018-01-25 23:19:41 +0800158
159 $userMap =
160 array(
161 Numberz::FIVE => 5,
162 Numberz::EIGHT => 8
163 );
164
165 $insanity2 =
166 new Insanity(
Jens Geyer9ea48f32019-11-02 12:20:29 +0100167 array(
Robert Lu12f124c2018-01-25 23:19:41 +0800168 'userMap' => $userMap,
169 'xtructs' => array($xtruct1, $xtruct2)
170 )
Jens Geyer9ea48f32019-11-02 12:20:29 +0100171 );
Robert Lu12f124c2018-01-25 23:19:41 +0800172
173 $insanity3 = $insanity2;
174
175 $insanity6 =
176 new Insanity(
Jens Geyer9ea48f32019-11-02 12:20:29 +0100177 array(
Robert Lu12f124c2018-01-25 23:19:41 +0800178 'userMap' => null,
179 'xtructs' => null
180 )
Jens Geyer9ea48f32019-11-02 12:20:29 +0100181 );
Robert Lu12f124c2018-01-25 23:19:41 +0800182
183 self::$testArgs['testInsanityExpectedResult'] =
184 array(
185 "1" => array(
186 Numberz::TWO => $insanity2,
187 Numberz::THREE => $insanity3
188 ),
189 "2" => array(
190 Numberz::SIX => $insanity6
191 )
192 );
Roger Meier21c0a852012-09-05 19:47:14 +0000193 }
Roger Meier21c0a852012-09-05 19:47:14 +0000194}