generated_class_test.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. <?php
  2. require_once('generated/NoNamespaceEnum.php');
  3. require_once('generated/NoNamespaceMessage.php');
  4. require_once('test_base.php');
  5. require_once('test_util.php');
  6. use Google\Protobuf\Internal\RepeatedField;
  7. use Google\Protobuf\Internal\MapField;
  8. use Google\Protobuf\Internal\GPBType;
  9. use Foo\TestEnum;
  10. use Foo\TestIncludeNamespaceMessage;
  11. use Foo\TestIncludePrefixMessage;
  12. use Foo\TestMessage;
  13. use Foo\TestMessage_Sub;
  14. use Foo\TestReverseFieldOrder;
  15. use Foo\testLowerCaseMessage;
  16. use Foo\testLowerCaseEnum;
  17. use Php\Test\TestNamespace;
  18. class GeneratedClassTest extends TestBase
  19. {
  20. #########################################################
  21. # Test field accessors.
  22. #########################################################
  23. public function testSetterGetter()
  24. {
  25. $m = new TestMessage();
  26. $m->setOptionalInt32(1);
  27. $this->assertSame(1, $m->getOptionalInt32());
  28. }
  29. #########################################################
  30. # Test int32 field.
  31. #########################################################
  32. public function testInt32Field()
  33. {
  34. $m = new TestMessage();
  35. // Set integer.
  36. $m->setOptionalInt32(MAX_INT32);
  37. $this->assertSame(MAX_INT32, $m->getOptionalInt32());
  38. $m->setOptionalInt32(MIN_INT32);
  39. $this->assertSame(MIN_INT32, $m->getOptionalInt32());
  40. // Set float.
  41. $m->setOptionalInt32(1.1);
  42. $this->assertSame(1, $m->getOptionalInt32());
  43. $m->setOptionalInt32(MAX_INT32_FLOAT);
  44. $this->assertSame(MAX_INT32, $m->getOptionalInt32());
  45. $m->setOptionalInt32(MIN_INT32_FLOAT);
  46. $this->assertSame(MIN_INT32, $m->getOptionalInt32());
  47. // Set string.
  48. $m->setOptionalInt32('2');
  49. $this->assertSame(2, $m->getOptionalInt32());
  50. $m->setOptionalInt32('3.1');
  51. $this->assertSame(3, $m->getOptionalInt32());
  52. $m->setOptionalInt32(MAX_INT32_STRING);
  53. $this->assertSame(MAX_INT32, $m->getOptionalInt32());
  54. $m->setOptionalInt32(MIN_INT32_STRING);
  55. $this->assertSame(MIN_INT32, $m->getOptionalInt32());
  56. }
  57. #########################################################
  58. # Test uint32 field.
  59. #########################################################
  60. public function testUint32Field()
  61. {
  62. $m = new TestMessage();
  63. // Set integer.
  64. $m->setOptionalUint32(MAX_UINT32);
  65. $this->assertSame(-1, $m->getOptionalUint32());
  66. $m->setOptionalUint32(-1);
  67. $this->assertSame(-1, $m->getOptionalUint32());
  68. $m->setOptionalUint32(MIN_UINT32);
  69. $this->assertSame(MIN_INT32, $m->getOptionalUint32());
  70. // Set float.
  71. $m->setOptionalUint32(1.1);
  72. $this->assertSame(1, $m->getOptionalUint32());
  73. $m->setOptionalUint32(MAX_UINT32_FLOAT);
  74. $this->assertSame(-1, $m->getOptionalUint32());
  75. $m->setOptionalUint32(-1.0);
  76. $this->assertSame(-1, $m->getOptionalUint32());
  77. $m->setOptionalUint32(MIN_UINT32_FLOAT);
  78. $this->assertSame(MIN_INT32, $m->getOptionalUint32());
  79. // Set string.
  80. $m->setOptionalUint32('2');
  81. $this->assertSame(2, $m->getOptionalUint32());
  82. $m->setOptionalUint32('3.1');
  83. $this->assertSame(3, $m->getOptionalUint32());
  84. $m->setOptionalUint32(MAX_UINT32_STRING);
  85. $this->assertSame(-1, $m->getOptionalUint32());
  86. $m->setOptionalUint32('-1.0');
  87. $this->assertSame(-1, $m->getOptionalUint32());
  88. $m->setOptionalUint32(MIN_UINT32_STRING);
  89. $this->assertSame(MIN_INT32, $m->getOptionalUint32());
  90. }
  91. #########################################################
  92. # Test int64 field.
  93. #########################################################
  94. public function testInt64Field()
  95. {
  96. $m = new TestMessage();
  97. // Set integer.
  98. $m->setOptionalInt64(MAX_INT64);
  99. $this->assertSame(MAX_INT64, $m->getOptionalInt64());
  100. $m->setOptionalInt64(MIN_INT64);
  101. $this->assertEquals(MIN_INT64, $m->getOptionalInt64());
  102. // Set float.
  103. $m->setOptionalInt64(1.1);
  104. if (PHP_INT_SIZE == 4) {
  105. $this->assertSame('1', $m->getOptionalInt64());
  106. } else {
  107. $this->assertSame(1, $m->getOptionalInt64());
  108. }
  109. // Set string.
  110. $m->setOptionalInt64('2');
  111. if (PHP_INT_SIZE == 4) {
  112. $this->assertSame('2', $m->getOptionalInt64());
  113. } else {
  114. $this->assertSame(2, $m->getOptionalInt64());
  115. }
  116. $m->setOptionalInt64('3.1');
  117. if (PHP_INT_SIZE == 4) {
  118. $this->assertSame('3', $m->getOptionalInt64());
  119. } else {
  120. $this->assertSame(3, $m->getOptionalInt64());
  121. }
  122. $m->setOptionalInt64(MAX_INT64_STRING);
  123. if (PHP_INT_SIZE == 4) {
  124. $this->assertSame(MAX_INT64_STRING, $m->getOptionalInt64());
  125. } else {
  126. $this->assertSame(MAX_INT64, $m->getOptionalInt64());
  127. }
  128. $m->setOptionalInt64(MIN_INT64_STRING);
  129. if (PHP_INT_SIZE == 4) {
  130. $this->assertSame(MIN_INT64_STRING, $m->getOptionalInt64());
  131. } else {
  132. $this->assertSame(MIN_INT64, $m->getOptionalInt64());
  133. }
  134. }
  135. #########################################################
  136. # Test uint64 field.
  137. #########################################################
  138. public function testUint64Field()
  139. {
  140. $m = new TestMessage();
  141. // Set integer.
  142. $m->setOptionalUint64(MAX_UINT64);
  143. if (PHP_INT_SIZE == 4) {
  144. $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64());
  145. } else {
  146. $this->assertSame(MAX_UINT64, $m->getOptionalUint64());
  147. }
  148. // Set float.
  149. $m->setOptionalUint64(1.1);
  150. if (PHP_INT_SIZE == 4) {
  151. $this->assertSame('1', $m->getOptionalUint64());
  152. } else {
  153. $this->assertSame(1, $m->getOptionalUint64());
  154. }
  155. // Set string.
  156. $m->setOptionalUint64('2');
  157. if (PHP_INT_SIZE == 4) {
  158. $this->assertSame('2', $m->getOptionalUint64());
  159. } else {
  160. $this->assertSame(2, $m->getOptionalUint64());
  161. }
  162. $m->setOptionalUint64('3.1');
  163. if (PHP_INT_SIZE == 4) {
  164. $this->assertSame('3', $m->getOptionalUint64());
  165. } else {
  166. $this->assertSame(3, $m->getOptionalUint64());
  167. }
  168. $m->setOptionalUint64(MAX_UINT64_STRING);
  169. if (PHP_INT_SIZE == 4) {
  170. $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64());
  171. } else {
  172. $this->assertSame(MAX_UINT64, $m->getOptionalUint64());
  173. }
  174. }
  175. #########################################################
  176. # Test enum field.
  177. #########################################################
  178. public function testEnumField()
  179. {
  180. $m = new TestMessage();
  181. // Set enum.
  182. $m->setOptionalEnum(TestEnum::ONE);
  183. $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
  184. // Set integer.
  185. $m->setOptionalEnum(1);
  186. $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
  187. // Set float.
  188. $m->setOptionalEnum(1.1);
  189. $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
  190. // Set string.
  191. $m->setOptionalEnum("1");
  192. $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
  193. }
  194. public function testNestedEnum()
  195. {
  196. $m = new TestMessage();
  197. $m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO);
  198. }
  199. #########################################################
  200. # Test float field.
  201. #########################################################
  202. public function testFloatField()
  203. {
  204. $m = new TestMessage();
  205. // Set integer.
  206. $m->setOptionalFloat(1);
  207. $this->assertEquals(1.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
  208. // Set float.
  209. $m->setOptionalFloat(1.1);
  210. $this->assertEquals(1.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
  211. // Set string.
  212. $m->setOptionalFloat('2');
  213. $this->assertEquals(2.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
  214. $m->setOptionalFloat('3.1');
  215. $this->assertEquals(3.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
  216. }
  217. #########################################################
  218. # Test double field.
  219. #########################################################
  220. public function testDoubleField()
  221. {
  222. $m = new TestMessage();
  223. // Set integer.
  224. $m->setOptionalDouble(1);
  225. $this->assertEquals(1.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
  226. // Set float.
  227. $m->setOptionalDouble(1.1);
  228. $this->assertEquals(1.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
  229. // Set string.
  230. $m->setOptionalDouble('2');
  231. $this->assertEquals(2.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
  232. $m->setOptionalDouble('3.1');
  233. $this->assertEquals(3.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
  234. }
  235. #########################################################
  236. # Test bool field.
  237. #########################################################
  238. public function testBoolField()
  239. {
  240. $m = new TestMessage();
  241. // Set bool.
  242. $m->setOptionalBool(true);
  243. $this->assertSame(true, $m->getOptionalBool());
  244. // Set integer.
  245. $m->setOptionalBool(-1);
  246. $this->assertSame(true, $m->getOptionalBool());
  247. // Set float.
  248. $m->setOptionalBool(1.1);
  249. $this->assertSame(true, $m->getOptionalBool());
  250. // Set string.
  251. $m->setOptionalBool('');
  252. $this->assertSame(false, $m->getOptionalBool());
  253. }
  254. #########################################################
  255. # Test string field.
  256. #########################################################
  257. public function testStringField()
  258. {
  259. $m = new TestMessage();
  260. // Set string.
  261. $m->setOptionalString('abc');
  262. $this->assertSame('abc', $m->getOptionalString());
  263. // Set integer.
  264. $m->setOptionalString(1);
  265. $this->assertSame('1', $m->getOptionalString());
  266. // Set double.
  267. $m->setOptionalString(1.1);
  268. $this->assertSame('1.1', $m->getOptionalString());
  269. // Set bool.
  270. $m->setOptionalString(true);
  271. $this->assertSame('1', $m->getOptionalString());
  272. }
  273. #########################################################
  274. # Test bytes field.
  275. #########################################################
  276. public function testBytesField()
  277. {
  278. $m = new TestMessage();
  279. // Set string.
  280. $m->setOptionalBytes('abc');
  281. $this->assertSame('abc', $m->getOptionalBytes());
  282. // Set integer.
  283. $m->setOptionalBytes(1);
  284. $this->assertSame('1', $m->getOptionalBytes());
  285. // Set double.
  286. $m->setOptionalBytes(1.1);
  287. $this->assertSame('1.1', $m->getOptionalBytes());
  288. // Set bool.
  289. $m->setOptionalBytes(true);
  290. $this->assertSame('1', $m->getOptionalBytes());
  291. }
  292. public function testBytesFieldInvalidUTF8Success()
  293. {
  294. $m = new TestMessage();
  295. $hex = hex2bin("ff");
  296. $m->setOptionalBytes($hex);
  297. }
  298. #########################################################
  299. # Test message field.
  300. #########################################################
  301. public function testMessageField()
  302. {
  303. $m = new TestMessage();
  304. $sub_m = new TestMessage_Sub();
  305. $sub_m->setA(1);
  306. $m->setOptionalMessage($sub_m);
  307. $this->assertSame(1, $m->getOptionalMessage()->getA());
  308. $null = null;
  309. $m->setOptionalMessage($null);
  310. $this->assertNull($m->getOptionalMessage());
  311. }
  312. #########################################################
  313. # Test repeated field.
  314. #########################################################
  315. public function testRepeatedField()
  316. {
  317. $m = new TestMessage();
  318. $repeated_int32 = new RepeatedField(GPBType::INT32);
  319. $m->setRepeatedInt32($repeated_int32);
  320. $this->assertSame($repeated_int32, $m->getRepeatedInt32());
  321. }
  322. public function testRepeatedFieldViaArray()
  323. {
  324. $m = new TestMessage();
  325. $arr = array();
  326. $m->setRepeatedInt32($arr);
  327. $this->assertSame(0, count($m->getRepeatedInt32()));
  328. $arr = array(1, 2.1, "3");
  329. $m->setRepeatedInt32($arr);
  330. $this->assertTrue($m->getRepeatedInt32() instanceof RepeatedField);
  331. $this->assertSame("Google\Protobuf\Internal\RepeatedField",
  332. get_class($m->getRepeatedInt32()));
  333. $this->assertSame(3, count($m->getRepeatedInt32()));
  334. $this->assertSame(1, $m->getRepeatedInt32()[0]);
  335. $this->assertSame(2, $m->getRepeatedInt32()[1]);
  336. $this->assertSame(3, $m->getRepeatedInt32()[2]);
  337. $this->assertFalse($arr instanceof RepeatedField);
  338. }
  339. #########################################################
  340. # Test map field.
  341. #########################################################
  342. public function testMapField()
  343. {
  344. $m = new TestMessage();
  345. $map_int32_int32 = new MapField(GPBType::INT32, GPBType::INT32);
  346. $m->setMapInt32Int32($map_int32_int32);
  347. $this->assertSame($map_int32_int32, $m->getMapInt32Int32());
  348. }
  349. public function testMapFieldViaArray()
  350. {
  351. $m = new TestMessage();
  352. $dict = array();
  353. $m->setMapInt32Int32($dict);
  354. $this->assertSame(0, count($m->getMapInt32Int32()));
  355. $dict = array(5 => 5, 6.1 => 6.1, "7" => "7");
  356. $m->setMapInt32Int32($dict);
  357. $this->assertTrue($m->getMapInt32Int32() instanceof MapField);
  358. $this->assertSame(3, count($m->getMapInt32Int32()));
  359. $this->assertSame(5, $m->getMapInt32Int32()[5]);
  360. $this->assertSame(6, $m->getMapInt32Int32()[6]);
  361. $this->assertSame(7, $m->getMapInt32Int32()[7]);
  362. $this->assertFalse($dict instanceof MapField);
  363. }
  364. #########################################################
  365. # Test oneof field.
  366. #########################################################
  367. public function testOneofField() {
  368. $m = new TestMessage();
  369. $this->assertSame("", $m->getMyOneof());
  370. $m->setOneofInt32(1);
  371. $this->assertSame(1, $m->getOneofInt32());
  372. $this->assertSame(0.0, $m->getOneofFloat());
  373. $this->assertSame('', $m->getOneofString());
  374. $this->assertSame(NULL, $m->getOneofMessage());
  375. $this->assertSame("oneof_int32", $m->getMyOneof());
  376. $m->setOneofFloat(2.0);
  377. $this->assertSame(0, $m->getOneofInt32());
  378. $this->assertSame(2.0, $m->getOneofFloat());
  379. $this->assertSame('', $m->getOneofString());
  380. $this->assertSame(NULL, $m->getOneofMessage());
  381. $this->assertSame("oneof_float", $m->getMyOneof());
  382. $m->setOneofString('abc');
  383. $this->assertSame(0, $m->getOneofInt32());
  384. $this->assertSame(0.0, $m->getOneofFloat());
  385. $this->assertSame('abc', $m->getOneofString());
  386. $this->assertSame(NULL, $m->getOneofMessage());
  387. $this->assertSame("oneof_string", $m->getMyOneof());
  388. $sub_m = new TestMessage_Sub();
  389. $sub_m->setA(1);
  390. $m->setOneofMessage($sub_m);
  391. $this->assertSame(0, $m->getOneofInt32());
  392. $this->assertSame(0.0, $m->getOneofFloat());
  393. $this->assertSame('', $m->getOneofString());
  394. $this->assertSame(1, $m->getOneofMessage()->getA());
  395. $this->assertSame("oneof_message", $m->getMyOneof());
  396. }
  397. #########################################################
  398. # Test clear method.
  399. #########################################################
  400. public function testMessageClear()
  401. {
  402. $m = new TestMessage();
  403. $this->setFields($m);
  404. $this->expectFields($m);
  405. $m->clear();
  406. $this->expectEmptyFields($m);
  407. }
  408. #########################################################
  409. # Test mergeFrom method.
  410. #########################################################
  411. public function testMessageMergeFrom()
  412. {
  413. $m = new TestMessage();
  414. $this->setFields($m);
  415. $this->expectFields($m);
  416. $arr = $m->getOptionalMessage()->getB();
  417. $arr[] = 1;
  418. $n = new TestMessage();
  419. // Singular
  420. $n->setOptionalInt32(100);
  421. $sub1 = new TestMessage_Sub();
  422. $sub1->setA(101);
  423. $b = $sub1->getB();
  424. $b[] = 102;
  425. $sub1->setB($b);
  426. $n->setOptionalMessage($sub1);
  427. // Repeated
  428. $repeatedInt32 = $n->getRepeatedInt32();
  429. $repeatedInt32[] = 200;
  430. $n->setRepeatedInt32($repeatedInt32);
  431. $repeatedString = $n->getRepeatedString();
  432. $repeatedString[] = 'abc';
  433. $n->setRepeatedString($repeatedString);
  434. $sub2 = new TestMessage_Sub();
  435. $sub2->setA(201);
  436. $repeatedMessage = $n->getRepeatedMessage();
  437. $repeatedMessage[] = $sub2;
  438. $n->setRepeatedMessage($repeatedMessage);
  439. // Map
  440. $mapInt32Int32 = $n->getMapInt32Int32();
  441. $mapInt32Int32[1] = 300;
  442. $mapInt32Int32[-62] = 301;
  443. $n->setMapInt32Int32($mapInt32Int32);
  444. $mapStringString = $n->getMapStringString();
  445. $mapStringString['def'] = 'def';
  446. $n->setMapStringString($mapStringString);
  447. $mapInt32Message = $n->getMapInt32Message();
  448. $mapInt32Message[1] = new TestMessage_Sub();
  449. $mapInt32Message[1]->setA(302);
  450. $mapInt32Message[2] = new TestMessage_Sub();
  451. $mapInt32Message[2]->setA(303);
  452. $n->setMapInt32Message($mapInt32Message);
  453. $m->mergeFrom($n);
  454. $this->assertSame(100, $m->getOptionalInt32());
  455. $this->assertSame(42, $m->getOptionalUint32());
  456. $this->assertSame(101, $m->getOptionalMessage()->getA());
  457. $this->assertSame(2, count($m->getOptionalMessage()->getB()));
  458. $this->assertSame(1, $m->getOptionalMessage()->getB()[0]);
  459. $this->assertSame(102, $m->getOptionalMessage()->getB()[1]);
  460. $this->assertSame(3, count($m->getRepeatedInt32()));
  461. $this->assertSame(200, $m->getRepeatedInt32()[2]);
  462. $this->assertSame(2, count($m->getRepeatedUint32()));
  463. $this->assertSame(3, count($m->getRepeatedString()));
  464. $this->assertSame('abc', $m->getRepeatedString()[2]);
  465. $this->assertSame(3, count($m->getRepeatedMessage()));
  466. $this->assertSame(201, $m->getRepeatedMessage()[2]->getA());
  467. $this->assertSame(2, count($m->getMapInt32Int32()));
  468. $this->assertSame(300, $m->getMapInt32Int32()[1]);
  469. $this->assertSame(301, $m->getMapInt32Int32()[-62]);
  470. $this->assertSame(1, count($m->getMapUint32Uint32()));
  471. $this->assertSame(2, count($m->getMapStringString()));
  472. $this->assertSame('def', $m->getMapStringString()['def']);
  473. $this->assertSame(2, count($m->getMapInt32Message()));
  474. $this->assertSame(302, $m->getMapInt32Message()[1]->getA());
  475. $this->assertSame(303, $m->getMapInt32Message()[2]->getA());
  476. $this->assertSame("", $m->getMyOneof());
  477. // Check sub-messages are copied by value.
  478. $n->getOptionalMessage()->setA(-101);
  479. $this->assertSame(101, $m->getOptionalMessage()->getA());
  480. $repeatedMessage = $n->getRepeatedMessage();
  481. $repeatedMessage[0]->setA(-201);
  482. $n->setRepeatedMessage($repeatedMessage);
  483. $this->assertSame(201, $m->getRepeatedMessage()[2]->getA());
  484. $mapInt32Message = $n->getMapInt32Message();
  485. $mapInt32Message[1]->setA(-302);
  486. $n->setMapInt32Message($mapInt32Message);
  487. $this->assertSame(302, $m->getMapInt32Message()[1]->getA());
  488. // Test merge oneof.
  489. $m = new TestMessage();
  490. $n = new TestMessage();
  491. $n->setOneofInt32(1);
  492. $m->mergeFrom($n);
  493. $this->assertSame(1, $m->getOneofInt32());
  494. $sub = new TestMessage_Sub();
  495. $n->setOneofMessage($sub);
  496. $n->getOneofMessage()->setA(400);
  497. $m->mergeFrom($n);
  498. $this->assertSame(400, $m->getOneofMessage()->getA());
  499. $n->getOneofMessage()->setA(-400);
  500. $this->assertSame(400, $m->getOneofMessage()->getA());
  501. // Test all fields
  502. $m = new TestMessage();
  503. $n = new TestMessage();
  504. $this->setFields($m);
  505. $n->mergeFrom($m);
  506. $this->expectFields($n);
  507. }
  508. #########################################################
  509. # Test message/enum without namespace.
  510. #########################################################
  511. public function testMessageWithoutNamespace()
  512. {
  513. $m = new TestMessage();
  514. $sub = new NoNameSpaceMessage();
  515. $m->setOptionalNoNamespaceMessage($sub);
  516. $repeatedNoNamespaceMessage = $m->getRepeatedNoNamespaceMessage();
  517. $repeatedNoNamespaceMessage[] = new NoNameSpaceMessage();
  518. $m->setRepeatedNoNamespaceMessage($repeatedNoNamespaceMessage);
  519. $n = new NoNamespaceMessage();
  520. $n->setB(NoNamespaceMessage_NestedEnum::ZERO);
  521. }
  522. public function testEnumWithoutNamespace()
  523. {
  524. $m = new TestMessage();
  525. $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A);
  526. $repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum();
  527. $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A;
  528. $m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum);
  529. }
  530. #########################################################
  531. # Test message with given prefix.
  532. #########################################################
  533. public function testPrefixMessage()
  534. {
  535. $m = new TestIncludePrefixMessage();
  536. $n = new PrefixTestPrefix();
  537. $n->setA(1);
  538. $m->setPrefixMessage($n);
  539. $this->assertSame(1, $m->getPrefixMessage()->getA());
  540. }
  541. #########################################################
  542. # Test message with given namespace.
  543. #########################################################
  544. public function testNamespaceMessage()
  545. {
  546. $m = new TestIncludeNamespaceMessage();
  547. $n = new TestNamespace();
  548. $n->setA(1);
  549. $m->setNamespaceMessage($n);
  550. $this->assertSame(1, $m->getNamespaceMessage()->getA());
  551. $n = new TestEmptyNamespace();
  552. $n->setA(1);
  553. $m->setEmptyNamespaceMessage($n);
  554. $this->assertSame(1, $m->getEmptyNamespaceMessage()->getA());
  555. }
  556. #########################################################
  557. # Test prefix for reserved words.
  558. #########################################################
  559. public function testPrefixForReservedWords()
  560. {
  561. $m = new \Foo\TestMessage_Empty();
  562. $m = new \Foo\PBEmpty();
  563. $m = new \PrefixEmpty();
  564. $m = new \Foo\PBARRAY();
  565. $m = new \Lower\PBabstract();
  566. $m = new \Lower\PBand();
  567. $m = new \Lower\PBarray();
  568. $m = new \Lower\PBas();
  569. $m = new \Lower\PBbreak();
  570. $m = new \Lower\PBcallable();
  571. $m = new \Lower\PBcase();
  572. $m = new \Lower\PBcatch();
  573. $m = new \Lower\PBclass();
  574. $m = new \Lower\PBclone();
  575. $m = new \Lower\PBconst();
  576. $m = new \Lower\PBcontinue();
  577. $m = new \Lower\PBdeclare();
  578. $m = new \Lower\PBdefault();
  579. $m = new \Lower\PBdie();
  580. $m = new \Lower\PBdo();
  581. $m = new \Lower\PBecho();
  582. $m = new \Lower\PBelse();
  583. $m = new \Lower\PBelseif();
  584. $m = new \Lower\PBempty();
  585. $m = new \Lower\PBenddeclare();
  586. $m = new \Lower\PBendfor();
  587. $m = new \Lower\PBendforeach();
  588. $m = new \Lower\PBendif();
  589. $m = new \Lower\PBendswitch();
  590. $m = new \Lower\PBendwhile();
  591. $m = new \Lower\PBeval();
  592. $m = new \Lower\PBexit();
  593. $m = new \Lower\PBextends();
  594. $m = new \Lower\PBfinal();
  595. $m = new \Lower\PBfor();
  596. $m = new \Lower\PBforeach();
  597. $m = new \Lower\PBfunction();
  598. $m = new \Lower\PBglobal();
  599. $m = new \Lower\PBgoto();
  600. $m = new \Lower\PBif();
  601. $m = new \Lower\PBimplements();
  602. $m = new \Lower\PBinclude();
  603. $m = new \Lower\PBinclude_once();
  604. $m = new \Lower\PBinstanceof();
  605. $m = new \Lower\PBinsteadof();
  606. $m = new \Lower\PBinterface();
  607. $m = new \Lower\PBisset();
  608. $m = new \Lower\PBlist();
  609. $m = new \Lower\PBnamespace();
  610. $m = new \Lower\PBnew();
  611. $m = new \Lower\PBor();
  612. $m = new \Lower\PBprint();
  613. $m = new \Lower\PBprivate();
  614. $m = new \Lower\PBprotected();
  615. $m = new \Lower\PBpublic();
  616. $m = new \Lower\PBrequire();
  617. $m = new \Lower\PBrequire_once();
  618. $m = new \Lower\PBreturn();
  619. $m = new \Lower\PBstatic();
  620. $m = new \Lower\PBswitch();
  621. $m = new \Lower\PBthrow();
  622. $m = new \Lower\PBtrait();
  623. $m = new \Lower\PBtry();
  624. $m = new \Lower\PBunset();
  625. $m = new \Lower\PBuse();
  626. $m = new \Lower\PBvar();
  627. $m = new \Lower\PBwhile();
  628. $m = new \Lower\PBxor();
  629. $m = new \Lower\PBint();
  630. $m = new \Lower\PBfloat();
  631. $m = new \Lower\PBbool();
  632. $m = new \Lower\PBstring();
  633. $m = new \Lower\PBtrue();
  634. $m = new \Lower\PBfalse();
  635. $m = new \Lower\PBnull();
  636. $m = new \Lower\PBvoid();
  637. $m = new \Lower\PBiterable();
  638. $m = new \Upper\PBABSTRACT();
  639. $m = new \Upper\PBAND();
  640. $m = new \Upper\PBARRAY();
  641. $m = new \Upper\PBAS();
  642. $m = new \Upper\PBBREAK();
  643. $m = new \Upper\PBCALLABLE();
  644. $m = new \Upper\PBCASE();
  645. $m = new \Upper\PBCATCH();
  646. $m = new \Upper\PBCLASS();
  647. $m = new \Upper\PBCLONE();
  648. $m = new \Upper\PBCONST();
  649. $m = new \Upper\PBCONTINUE();
  650. $m = new \Upper\PBDECLARE();
  651. $m = new \Upper\PBDEFAULT();
  652. $m = new \Upper\PBDIE();
  653. $m = new \Upper\PBDO();
  654. $m = new \Upper\PBECHO();
  655. $m = new \Upper\PBELSE();
  656. $m = new \Upper\PBELSEIF();
  657. $m = new \Upper\PBEMPTY();
  658. $m = new \Upper\PBENDDECLARE();
  659. $m = new \Upper\PBENDFOR();
  660. $m = new \Upper\PBENDFOREACH();
  661. $m = new \Upper\PBENDIF();
  662. $m = new \Upper\PBENDSWITCH();
  663. $m = new \Upper\PBENDWHILE();
  664. $m = new \Upper\PBEVAL();
  665. $m = new \Upper\PBEXIT();
  666. $m = new \Upper\PBEXTENDS();
  667. $m = new \Upper\PBFINAL();
  668. $m = new \Upper\PBFOR();
  669. $m = new \Upper\PBFOREACH();
  670. $m = new \Upper\PBFUNCTION();
  671. $m = new \Upper\PBGLOBAL();
  672. $m = new \Upper\PBGOTO();
  673. $m = new \Upper\PBIF();
  674. $m = new \Upper\PBIMPLEMENTS();
  675. $m = new \Upper\PBINCLUDE();
  676. $m = new \Upper\PBINCLUDE_ONCE();
  677. $m = new \Upper\PBINSTANCEOF();
  678. $m = new \Upper\PBINSTEADOF();
  679. $m = new \Upper\PBINTERFACE();
  680. $m = new \Upper\PBISSET();
  681. $m = new \Upper\PBLIST();
  682. $m = new \Upper\PBNAMESPACE();
  683. $m = new \Upper\PBNEW();
  684. $m = new \Upper\PBOR();
  685. $m = new \Upper\PBPRINT();
  686. $m = new \Upper\PBPRIVATE();
  687. $m = new \Upper\PBPROTECTED();
  688. $m = new \Upper\PBPUBLIC();
  689. $m = new \Upper\PBREQUIRE();
  690. $m = new \Upper\PBREQUIRE_ONCE();
  691. $m = new \Upper\PBRETURN();
  692. $m = new \Upper\PBSTATIC();
  693. $m = new \Upper\PBSWITCH();
  694. $m = new \Upper\PBTHROW();
  695. $m = new \Upper\PBTRAIT();
  696. $m = new \Upper\PBTRY();
  697. $m = new \Upper\PBUNSET();
  698. $m = new \Upper\PBUSE();
  699. $m = new \Upper\PBVAR();
  700. $m = new \Upper\PBWHILE();
  701. $m = new \Upper\PBXOR();
  702. $m = new \Upper\PBINT();
  703. $m = new \Upper\PBFLOAT();
  704. $m = new \Upper\PBBOOL();
  705. $m = new \Upper\PBSTRING();
  706. $m = new \Upper\PBTRUE();
  707. $m = new \Upper\PBFALSE();
  708. $m = new \Upper\PBNULL();
  709. $m = new \Upper\PBVOID();
  710. $m = new \Upper\PBITERABLE();
  711. $m = new \Lower_enum\PBabstract();
  712. $m = new \Lower_enum\PBand();
  713. $m = new \Lower_enum\PBarray();
  714. $m = new \Lower_enum\PBas();
  715. $m = new \Lower_enum\PBbreak();
  716. $m = new \Lower_enum\PBcallable();
  717. $m = new \Lower_enum\PBcase();
  718. $m = new \Lower_enum\PBcatch();
  719. $m = new \Lower_enum\PBclass();
  720. $m = new \Lower_enum\PBclone();
  721. $m = new \Lower_enum\PBconst();
  722. $m = new \Lower_enum\PBcontinue();
  723. $m = new \Lower_enum\PBdeclare();
  724. $m = new \Lower_enum\PBdefault();
  725. $m = new \Lower_enum\PBdie();
  726. $m = new \Lower_enum\PBdo();
  727. $m = new \Lower_enum\PBecho();
  728. $m = new \Lower_enum\PBelse();
  729. $m = new \Lower_enum\PBelseif();
  730. $m = new \Lower_enum\PBempty();
  731. $m = new \Lower_enum\PBenddeclare();
  732. $m = new \Lower_enum\PBendfor();
  733. $m = new \Lower_enum\PBendforeach();
  734. $m = new \Lower_enum\PBendif();
  735. $m = new \Lower_enum\PBendswitch();
  736. $m = new \Lower_enum\PBendwhile();
  737. $m = new \Lower_enum\PBeval();
  738. $m = new \Lower_enum\PBexit();
  739. $m = new \Lower_enum\PBextends();
  740. $m = new \Lower_enum\PBfinal();
  741. $m = new \Lower_enum\PBfor();
  742. $m = new \Lower_enum\PBforeach();
  743. $m = new \Lower_enum\PBfunction();
  744. $m = new \Lower_enum\PBglobal();
  745. $m = new \Lower_enum\PBgoto();
  746. $m = new \Lower_enum\PBif();
  747. $m = new \Lower_enum\PBimplements();
  748. $m = new \Lower_enum\PBinclude();
  749. $m = new \Lower_enum\PBinclude_once();
  750. $m = new \Lower_enum\PBinstanceof();
  751. $m = new \Lower_enum\PBinsteadof();
  752. $m = new \Lower_enum\PBinterface();
  753. $m = new \Lower_enum\PBisset();
  754. $m = new \Lower_enum\PBlist();
  755. $m = new \Lower_enum\PBnamespace();
  756. $m = new \Lower_enum\PBnew();
  757. $m = new \Lower_enum\PBor();
  758. $m = new \Lower_enum\PBprint();
  759. $m = new \Lower_enum\PBprivate();
  760. $m = new \Lower_enum\PBprotected();
  761. $m = new \Lower_enum\PBpublic();
  762. $m = new \Lower_enum\PBrequire();
  763. $m = new \Lower_enum\PBrequire_once();
  764. $m = new \Lower_enum\PBreturn();
  765. $m = new \Lower_enum\PBstatic();
  766. $m = new \Lower_enum\PBswitch();
  767. $m = new \Lower_enum\PBthrow();
  768. $m = new \Lower_enum\PBtrait();
  769. $m = new \Lower_enum\PBtry();
  770. $m = new \Lower_enum\PBunset();
  771. $m = new \Lower_enum\PBuse();
  772. $m = new \Lower_enum\PBvar();
  773. $m = new \Lower_enum\PBwhile();
  774. $m = new \Lower_enum\PBxor();
  775. $m = new \Lower_enum\PBint();
  776. $m = new \Lower_enum\PBfloat();
  777. $m = new \Lower_enum\PBbool();
  778. $m = new \Lower_enum\PBstring();
  779. $m = new \Lower_enum\PBtrue();
  780. $m = new \Lower_enum\PBfalse();
  781. $m = new \Lower_enum\PBnull();
  782. $m = new \Lower_enum\PBvoid();
  783. $m = new \Lower_enum\PBiterable();
  784. $m = new \Upper_enum\PBABSTRACT();
  785. $m = new \Upper_enum\PBAND();
  786. $m = new \Upper_enum\PBARRAY();
  787. $m = new \Upper_enum\PBAS();
  788. $m = new \Upper_enum\PBBREAK();
  789. $m = new \Upper_enum\PBCALLABLE();
  790. $m = new \Upper_enum\PBCASE();
  791. $m = new \Upper_enum\PBCATCH();
  792. $m = new \Upper_enum\PBCLASS();
  793. $m = new \Upper_enum\PBCLONE();
  794. $m = new \Upper_enum\PBCONST();
  795. $m = new \Upper_enum\PBCONTINUE();
  796. $m = new \Upper_enum\PBDECLARE();
  797. $m = new \Upper_enum\PBDEFAULT();
  798. $m = new \Upper_enum\PBDIE();
  799. $m = new \Upper_enum\PBDO();
  800. $m = new \Upper_enum\PBECHO();
  801. $m = new \Upper_enum\PBELSE();
  802. $m = new \Upper_enum\PBELSEIF();
  803. $m = new \Upper_enum\PBEMPTY();
  804. $m = new \Upper_enum\PBENDDECLARE();
  805. $m = new \Upper_enum\PBENDFOR();
  806. $m = new \Upper_enum\PBENDFOREACH();
  807. $m = new \Upper_enum\PBENDIF();
  808. $m = new \Upper_enum\PBENDSWITCH();
  809. $m = new \Upper_enum\PBENDWHILE();
  810. $m = new \Upper_enum\PBEVAL();
  811. $m = new \Upper_enum\PBEXIT();
  812. $m = new \Upper_enum\PBEXTENDS();
  813. $m = new \Upper_enum\PBFINAL();
  814. $m = new \Upper_enum\PBFOR();
  815. $m = new \Upper_enum\PBFOREACH();
  816. $m = new \Upper_enum\PBFUNCTION();
  817. $m = new \Upper_enum\PBGLOBAL();
  818. $m = new \Upper_enum\PBGOTO();
  819. $m = new \Upper_enum\PBIF();
  820. $m = new \Upper_enum\PBIMPLEMENTS();
  821. $m = new \Upper_enum\PBINCLUDE();
  822. $m = new \Upper_enum\PBINCLUDE_ONCE();
  823. $m = new \Upper_enum\PBINSTANCEOF();
  824. $m = new \Upper_enum\PBINSTEADOF();
  825. $m = new \Upper_enum\PBINTERFACE();
  826. $m = new \Upper_enum\PBISSET();
  827. $m = new \Upper_enum\PBLIST();
  828. $m = new \Upper_enum\PBNAMESPACE();
  829. $m = new \Upper_enum\PBNEW();
  830. $m = new \Upper_enum\PBOR();
  831. $m = new \Upper_enum\PBPRINT();
  832. $m = new \Upper_enum\PBPRIVATE();
  833. $m = new \Upper_enum\PBPROTECTED();
  834. $m = new \Upper_enum\PBPUBLIC();
  835. $m = new \Upper_enum\PBREQUIRE();
  836. $m = new \Upper_enum\PBREQUIRE_ONCE();
  837. $m = new \Upper_enum\PBRETURN();
  838. $m = new \Upper_enum\PBSTATIC();
  839. $m = new \Upper_enum\PBSWITCH();
  840. $m = new \Upper_enum\PBTHROW();
  841. $m = new \Upper_enum\PBTRAIT();
  842. $m = new \Upper_enum\PBTRY();
  843. $m = new \Upper_enum\PBUNSET();
  844. $m = new \Upper_enum\PBUSE();
  845. $m = new \Upper_enum\PBVAR();
  846. $m = new \Upper_enum\PBWHILE();
  847. $m = new \Upper_enum\PBXOR();
  848. $m = new \Upper_enum\PBINT();
  849. $m = new \Upper_enum\PBFLOAT();
  850. $m = new \Upper_enum\PBBOOL();
  851. $m = new \Upper_enum\PBSTRING();
  852. $m = new \Upper_enum\PBTRUE();
  853. $m = new \Upper_enum\PBFALSE();
  854. $m = new \Upper_enum\PBNULL();
  855. $m = new \Upper_enum\PBVOID();
  856. $m = new \Upper_enum\PBITERABLE();
  857. $m = \Lower_enum_value\NotAllowed::PBabstract;
  858. $m = \Lower_enum_value\NotAllowed::PBand;
  859. $m = \Lower_enum_value\NotAllowed::PBarray;
  860. $m = \Lower_enum_value\NotAllowed::PBas;
  861. $m = \Lower_enum_value\NotAllowed::PBbreak;
  862. $m = \Lower_enum_value\NotAllowed::PBcallable;
  863. $m = \Lower_enum_value\NotAllowed::PBcase;
  864. $m = \Lower_enum_value\NotAllowed::PBcatch;
  865. $m = \Lower_enum_value\NotAllowed::PBclass;
  866. $m = \Lower_enum_value\NotAllowed::PBclone;
  867. $m = \Lower_enum_value\NotAllowed::PBconst;
  868. $m = \Lower_enum_value\NotAllowed::PBcontinue;
  869. $m = \Lower_enum_value\NotAllowed::PBdeclare;
  870. $m = \Lower_enum_value\NotAllowed::PBdefault;
  871. $m = \Lower_enum_value\NotAllowed::PBdie;
  872. $m = \Lower_enum_value\NotAllowed::PBdo;
  873. $m = \Lower_enum_value\NotAllowed::PBecho;
  874. $m = \Lower_enum_value\NotAllowed::PBelse;
  875. $m = \Lower_enum_value\NotAllowed::PBelseif;
  876. $m = \Lower_enum_value\NotAllowed::PBempty;
  877. $m = \Lower_enum_value\NotAllowed::PBenddeclare;
  878. $m = \Lower_enum_value\NotAllowed::PBendfor;
  879. $m = \Lower_enum_value\NotAllowed::PBendforeach;
  880. $m = \Lower_enum_value\NotAllowed::PBendif;
  881. $m = \Lower_enum_value\NotAllowed::PBendswitch;
  882. $m = \Lower_enum_value\NotAllowed::PBendwhile;
  883. $m = \Lower_enum_value\NotAllowed::PBeval;
  884. $m = \Lower_enum_value\NotAllowed::PBexit;
  885. $m = \Lower_enum_value\NotAllowed::PBextends;
  886. $m = \Lower_enum_value\NotAllowed::PBfinal;
  887. $m = \Lower_enum_value\NotAllowed::PBfor;
  888. $m = \Lower_enum_value\NotAllowed::PBforeach;
  889. $m = \Lower_enum_value\NotAllowed::PBfunction;
  890. $m = \Lower_enum_value\NotAllowed::PBglobal;
  891. $m = \Lower_enum_value\NotAllowed::PBgoto;
  892. $m = \Lower_enum_value\NotAllowed::PBif;
  893. $m = \Lower_enum_value\NotAllowed::PBimplements;
  894. $m = \Lower_enum_value\NotAllowed::PBinclude;
  895. $m = \Lower_enum_value\NotAllowed::PBinclude_once;
  896. $m = \Lower_enum_value\NotAllowed::PBinstanceof;
  897. $m = \Lower_enum_value\NotAllowed::PBinsteadof;
  898. $m = \Lower_enum_value\NotAllowed::PBinterface;
  899. $m = \Lower_enum_value\NotAllowed::PBisset;
  900. $m = \Lower_enum_value\NotAllowed::PBlist;
  901. $m = \Lower_enum_value\NotAllowed::PBnamespace;
  902. $m = \Lower_enum_value\NotAllowed::PBnew;
  903. $m = \Lower_enum_value\NotAllowed::PBor;
  904. $m = \Lower_enum_value\NotAllowed::PBprint;
  905. $m = \Lower_enum_value\NotAllowed::PBprivate;
  906. $m = \Lower_enum_value\NotAllowed::PBprotected;
  907. $m = \Lower_enum_value\NotAllowed::PBpublic;
  908. $m = \Lower_enum_value\NotAllowed::PBrequire;
  909. $m = \Lower_enum_value\NotAllowed::PBrequire_once;
  910. $m = \Lower_enum_value\NotAllowed::PBreturn;
  911. $m = \Lower_enum_value\NotAllowed::PBstatic;
  912. $m = \Lower_enum_value\NotAllowed::PBswitch;
  913. $m = \Lower_enum_value\NotAllowed::PBthrow;
  914. $m = \Lower_enum_value\NotAllowed::PBtrait;
  915. $m = \Lower_enum_value\NotAllowed::PBtry;
  916. $m = \Lower_enum_value\NotAllowed::PBunset;
  917. $m = \Lower_enum_value\NotAllowed::PBuse;
  918. $m = \Lower_enum_value\NotAllowed::PBvar;
  919. $m = \Lower_enum_value\NotAllowed::PBwhile;
  920. $m = \Lower_enum_value\NotAllowed::PBxor;
  921. $m = \Lower_enum_value\NotAllowed::int;
  922. $m = \Lower_enum_value\NotAllowed::float;
  923. $m = \Lower_enum_value\NotAllowed::bool;
  924. $m = \Lower_enum_value\NotAllowed::string;
  925. $m = \Lower_enum_value\NotAllowed::true;
  926. $m = \Lower_enum_value\NotAllowed::false;
  927. $m = \Lower_enum_value\NotAllowed::null;
  928. $m = \Lower_enum_value\NotAllowed::void;
  929. $m = \Lower_enum_value\NotAllowed::iterable;
  930. $m = \Upper_enum_value\NotAllowed::PBABSTRACT;
  931. $m = \Upper_enum_value\NotAllowed::PBAND;
  932. $m = \Upper_enum_value\NotAllowed::PBARRAY;
  933. $m = \Upper_enum_value\NotAllowed::PBAS;
  934. $m = \Upper_enum_value\NotAllowed::PBBREAK;
  935. $m = \Upper_enum_value\NotAllowed::PBCALLABLE;
  936. $m = \Upper_enum_value\NotAllowed::PBCASE;
  937. $m = \Upper_enum_value\NotAllowed::PBCATCH;
  938. $m = \Upper_enum_value\NotAllowed::PBCLASS;
  939. $m = \Upper_enum_value\NotAllowed::PBCLONE;
  940. $m = \Upper_enum_value\NotAllowed::PBCONST;
  941. $m = \Upper_enum_value\NotAllowed::PBCONTINUE;
  942. $m = \Upper_enum_value\NotAllowed::PBDECLARE;
  943. $m = \Upper_enum_value\NotAllowed::PBDEFAULT;
  944. $m = \Upper_enum_value\NotAllowed::PBDIE;
  945. $m = \Upper_enum_value\NotAllowed::PBDO;
  946. $m = \Upper_enum_value\NotAllowed::PBECHO;
  947. $m = \Upper_enum_value\NotAllowed::PBELSE;
  948. $m = \Upper_enum_value\NotAllowed::PBELSEIF;
  949. $m = \Upper_enum_value\NotAllowed::PBEMPTY;
  950. $m = \Upper_enum_value\NotAllowed::PBENDDECLARE;
  951. $m = \Upper_enum_value\NotAllowed::PBENDFOR;
  952. $m = \Upper_enum_value\NotAllowed::PBENDFOREACH;
  953. $m = \Upper_enum_value\NotAllowed::PBENDIF;
  954. $m = \Upper_enum_value\NotAllowed::PBENDSWITCH;
  955. $m = \Upper_enum_value\NotAllowed::PBENDWHILE;
  956. $m = \Upper_enum_value\NotAllowed::PBEVAL;
  957. $m = \Upper_enum_value\NotAllowed::PBEXIT;
  958. $m = \Upper_enum_value\NotAllowed::PBEXTENDS;
  959. $m = \Upper_enum_value\NotAllowed::PBFINAL;
  960. $m = \Upper_enum_value\NotAllowed::PBFOR;
  961. $m = \Upper_enum_value\NotAllowed::PBFOREACH;
  962. $m = \Upper_enum_value\NotAllowed::PBFUNCTION;
  963. $m = \Upper_enum_value\NotAllowed::PBGLOBAL;
  964. $m = \Upper_enum_value\NotAllowed::PBGOTO;
  965. $m = \Upper_enum_value\NotAllowed::PBIF;
  966. $m = \Upper_enum_value\NotAllowed::PBIMPLEMENTS;
  967. $m = \Upper_enum_value\NotAllowed::PBINCLUDE;
  968. $m = \Upper_enum_value\NotAllowed::PBINCLUDE_ONCE;
  969. $m = \Upper_enum_value\NotAllowed::PBINSTANCEOF;
  970. $m = \Upper_enum_value\NotAllowed::PBINSTEADOF;
  971. $m = \Upper_enum_value\NotAllowed::PBINTERFACE;
  972. $m = \Upper_enum_value\NotAllowed::PBISSET;
  973. $m = \Upper_enum_value\NotAllowed::PBLIST;
  974. $m = \Upper_enum_value\NotAllowed::PBNAMESPACE;
  975. $m = \Upper_enum_value\NotAllowed::PBNEW;
  976. $m = \Upper_enum_value\NotAllowed::PBOR;
  977. $m = \Upper_enum_value\NotAllowed::PBPRINT;
  978. $m = \Upper_enum_value\NotAllowed::PBPRIVATE;
  979. $m = \Upper_enum_value\NotAllowed::PBPROTECTED;
  980. $m = \Upper_enum_value\NotAllowed::PBPUBLIC;
  981. $m = \Upper_enum_value\NotAllowed::PBREQUIRE;
  982. $m = \Upper_enum_value\NotAllowed::PBREQUIRE_ONCE;
  983. $m = \Upper_enum_value\NotAllowed::PBRETURN;
  984. $m = \Upper_enum_value\NotAllowed::PBSTATIC;
  985. $m = \Upper_enum_value\NotAllowed::PBSWITCH;
  986. $m = \Upper_enum_value\NotAllowed::PBTHROW;
  987. $m = \Upper_enum_value\NotAllowed::PBTRAIT;
  988. $m = \Upper_enum_value\NotAllowed::PBTRY;
  989. $m = \Upper_enum_value\NotAllowed::PBUNSET;
  990. $m = \Upper_enum_value\NotAllowed::PBUSE;
  991. $m = \Upper_enum_value\NotAllowed::PBVAR;
  992. $m = \Upper_enum_value\NotAllowed::PBWHILE;
  993. $m = \Upper_enum_value\NotAllowed::PBXOR;
  994. $m = \Upper_enum_value\NotAllowed::INT;
  995. $m = \Upper_enum_value\NotAllowed::FLOAT;
  996. $m = \Upper_enum_value\NotAllowed::BOOL;
  997. $m = \Upper_enum_value\NotAllowed::STRING;
  998. $m = \Upper_enum_value\NotAllowed::TRUE;
  999. $m = \Upper_enum_value\NotAllowed::FALSE;
  1000. $m = \Upper_enum_value\NotAllowed::NULL;
  1001. $m = \Upper_enum_value\NotAllowed::VOID;
  1002. $m = \Upper_enum_value\NotAllowed::ITERABLE;
  1003. }
  1004. #########################################################
  1005. # Test fluent setters.
  1006. #########################################################
  1007. public function testFluentSetters()
  1008. {
  1009. $m = (new TestMessage())
  1010. ->setOptionalInt32(1)
  1011. ->setOptionalUInt32(2);
  1012. $this->assertSame(1, $m->getOptionalInt32());
  1013. $this->assertSame(2, $m->getOptionalUInt32());
  1014. }
  1015. #########################################################
  1016. # Test Reverse Field Order.
  1017. #########################################################
  1018. public function testReverseFieldOrder()
  1019. {
  1020. $m = new TestReverseFieldOrder();
  1021. $m->setB("abc");
  1022. $this->assertSame("abc", $m->getB());
  1023. $this->assertNotSame("abc", $m->getA());
  1024. }
  1025. #########################################################
  1026. # Test Reverse Field Order.
  1027. #########################################################
  1028. public function testLowerCase()
  1029. {
  1030. $m = new testLowerCaseMessage();
  1031. $n = testLowerCaseEnum::VALUE;
  1032. }
  1033. }