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 24namespace Test\Thrift; 25 26use ThriftTest\Xtruct; 27use ThriftTest\Xtruct2; 28use ThriftTest\Numberz; 29use ThriftTest\Insanity; 30 31class Fixtures 32{ 33 public static $bufsize = 8192; //big enough to read biggest serialized Fixture arg. 34 public static $testArgs = array(); 35 36 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ú, 粵語"; 39 40 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: !@#\$%&()(&%$#{}{}<><><"; 46 47 self::$testArgs['testString3'] = 48 "string that ends in double-backslash \\\\"; 49 50 self::$testArgs['testUnicodeStringWithNonBMP'] = 51 "สวัสดี/"; 52 53 self::$testArgs['testDouble'] = 3.1415926535898; 54 55 // TODO: add testBinary() call 56 57 self::$testArgs['testByte'] = 0x01; 58 59 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( 69 array( 70 'string_thing' => 'worked', 71 'byte_thing' => 0x01, 72 'i32_thing' => pow(2, 30), 73 'i64_thing' => self::$testArgs['testI64'] 74 ) 75 ); 76 77 self::$testArgs['testNestNested'] = 78 new Xtruct( 79 array( 80 'string_thing' => 'worked', 81 'byte_thing' => 0x01, 82 'i32_thing' => pow(2, 30), 83 'i64_thing' => self::$testArgs['testI64'] 84 ) 85 ); 86 87 self::$testArgs['testNest'] = 88 new Xtruct2( 89 array( 90 'byte_thing' => 0x01, 91 'struct_thing' => self::$testArgs['testNestNested'], 92 'i32_thing' => pow(2, 15) 93 ) 94 ); 95 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( 141 array( 142 'string_thing' => 'Goodbye4', 143 'byte_thing' => 4, 144 'i32_thing' => 4, 145 'i64_thing' => 4 146 ) 147 ); 148 149 $xtruct2 = 150 new Xtruct( 151 array( 152 'string_thing' => 'Hello2', 153 'byte_thing' => 2, 154 'i32_thing' => 2, 155 'i64_thing' => 2 156 ) 157 ); 158 159 $userMap = 160 array( 161 Numberz::FIVE => 5, 162 Numberz::EIGHT => 8 163 ); 164 165 $insanity2 = 166 new Insanity( 167 array( 168 'userMap' => $userMap, 169 'xtructs' => array($xtruct1, $xtruct2) 170 ) 171 ); 172 173 $insanity3 = $insanity2; 174 175 $insanity6 = 176 new Insanity( 177 array( 178 'userMap' => null, 179 'xtructs' => null 180 ) 181 ); 182 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 ); 193 } 194} 195