1ffe3c632Sopenharmony_ci<?php
2ffe3c632Sopenharmony_ci
3ffe3c632Sopenharmony_ciuse Foo\TestMessage;
4ffe3c632Sopenharmony_ciuse Foo\TestEnum;
5ffe3c632Sopenharmony_ciuse Foo\TestMessage\Sub;
6ffe3c632Sopenharmony_ci
7ffe3c632Sopenharmony_ciclass TestBase extends \PHPUnit\Framework\TestCase
8ffe3c632Sopenharmony_ci{
9ffe3c632Sopenharmony_ci
10ffe3c632Sopenharmony_ci    public function setFields(TestMessage $m)
11ffe3c632Sopenharmony_ci    {
12ffe3c632Sopenharmony_ci        TestUtil::setTestMessage($m);
13ffe3c632Sopenharmony_ci    }
14ffe3c632Sopenharmony_ci
15ffe3c632Sopenharmony_ci    public function setFields2(TestMessage $m)
16ffe3c632Sopenharmony_ci    {
17ffe3c632Sopenharmony_ci        TestUtil::setTestMessage2($m);
18ffe3c632Sopenharmony_ci    }
19ffe3c632Sopenharmony_ci
20ffe3c632Sopenharmony_ci    public function expectFields(TestMessage $m)
21ffe3c632Sopenharmony_ci    {
22ffe3c632Sopenharmony_ci        $this->assertSame(-42,  $m->getOptionalInt32());
23ffe3c632Sopenharmony_ci        $this->assertSame(42,  $m->getOptionalUint32());
24ffe3c632Sopenharmony_ci        $this->assertSame(-44,  $m->getOptionalSint32());
25ffe3c632Sopenharmony_ci        $this->assertSame(46,   $m->getOptionalFixed32());
26ffe3c632Sopenharmony_ci        $this->assertSame(-46,  $m->getOptionalSfixed32());
27ffe3c632Sopenharmony_ci        $this->assertSame(1.5,  $m->getOptionalFloat());
28ffe3c632Sopenharmony_ci        $this->assertSame(1.6,  $m->getOptionalDouble());
29ffe3c632Sopenharmony_ci        $this->assertSame(true, $m->getOptionalBool());
30ffe3c632Sopenharmony_ci        $this->assertSame('a',  $m->getOptionalString());
31ffe3c632Sopenharmony_ci        $this->assertSame('bbbb',  $m->getOptionalBytes());
32ffe3c632Sopenharmony_ci        $this->assertSame(TestEnum::ONE, $m->getOptionalEnum());
33ffe3c632Sopenharmony_ci        $this->assertSame(33,   $m->getOptionalMessage()->getA());
34ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
35ffe3c632Sopenharmony_ci            $this->assertSame('-43',  $m->getOptionalInt64());
36ffe3c632Sopenharmony_ci            $this->assertSame('43',   $m->getOptionalUint64());
37ffe3c632Sopenharmony_ci            $this->assertSame('-45',  $m->getOptionalSint64());
38ffe3c632Sopenharmony_ci            $this->assertSame('47',   $m->getOptionalFixed64());
39ffe3c632Sopenharmony_ci            $this->assertSame('-47',  $m->getOptionalSfixed64());
40ffe3c632Sopenharmony_ci        } else {
41ffe3c632Sopenharmony_ci            $this->assertSame(-43,  $m->getOptionalInt64());
42ffe3c632Sopenharmony_ci            $this->assertSame(43,   $m->getOptionalUint64());
43ffe3c632Sopenharmony_ci            $this->assertSame(-45,  $m->getOptionalSint64());
44ffe3c632Sopenharmony_ci            $this->assertSame(47,   $m->getOptionalFixed64());
45ffe3c632Sopenharmony_ci            $this->assertSame(-47,  $m->getOptionalSfixed64());
46ffe3c632Sopenharmony_ci        }
47ffe3c632Sopenharmony_ci
48ffe3c632Sopenharmony_ci        $this->assertEquals(-42,  $m->getRepeatedInt32()[0]);
49ffe3c632Sopenharmony_ci        $this->assertEquals(42,   $m->getRepeatedUint32()[0]);
50ffe3c632Sopenharmony_ci        $this->assertEquals(-43,  $m->getRepeatedInt64()[0]);
51ffe3c632Sopenharmony_ci        $this->assertEquals(43,   $m->getRepeatedUint64()[0]);
52ffe3c632Sopenharmony_ci        $this->assertEquals(-44,  $m->getRepeatedSint32()[0]);
53ffe3c632Sopenharmony_ci        $this->assertEquals(-45,  $m->getRepeatedSint64()[0]);
54ffe3c632Sopenharmony_ci        $this->assertEquals(46,   $m->getRepeatedFixed32()[0]);
55ffe3c632Sopenharmony_ci        $this->assertEquals(47,   $m->getRepeatedFixed64()[0]);
56ffe3c632Sopenharmony_ci        $this->assertEquals(-46,  $m->getRepeatedSfixed32()[0]);
57ffe3c632Sopenharmony_ci        $this->assertEquals(-47,  $m->getRepeatedSfixed64()[0]);
58ffe3c632Sopenharmony_ci        $this->assertEquals(1.5,  $m->getRepeatedFloat()[0]);
59ffe3c632Sopenharmony_ci        $this->assertEquals(1.6,  $m->getRepeatedDouble()[0]);
60ffe3c632Sopenharmony_ci        $this->assertEquals(true, $m->getRepeatedBool()[0]);
61ffe3c632Sopenharmony_ci        $this->assertEquals('a',  $m->getRepeatedString()[0]);
62ffe3c632Sopenharmony_ci        $this->assertEquals('bbbb',  $m->getRepeatedBytes()[0]);
63ffe3c632Sopenharmony_ci        $this->assertEquals(34,   $m->getRepeatedMessage()[0]->GetA());
64ffe3c632Sopenharmony_ci
65ffe3c632Sopenharmony_ci        $this->assertEquals(-52,   $m->getRepeatedInt32()[1]);
66ffe3c632Sopenharmony_ci        $this->assertEquals(52,    $m->getRepeatedUint32()[1]);
67ffe3c632Sopenharmony_ci        $this->assertEquals(-53,   $m->getRepeatedInt64()[1]);
68ffe3c632Sopenharmony_ci        $this->assertEquals(53,    $m->getRepeatedUint64()[1]);
69ffe3c632Sopenharmony_ci        $this->assertEquals(-54,   $m->getRepeatedSint32()[1]);
70ffe3c632Sopenharmony_ci        $this->assertEquals(-55,   $m->getRepeatedSint64()[1]);
71ffe3c632Sopenharmony_ci        $this->assertEquals(56,    $m->getRepeatedFixed32()[1]);
72ffe3c632Sopenharmony_ci        $this->assertEquals(57,    $m->getRepeatedFixed64()[1]);
73ffe3c632Sopenharmony_ci        $this->assertEquals(-56,   $m->getRepeatedSfixed32()[1]);
74ffe3c632Sopenharmony_ci        $this->assertEquals(-57,   $m->getRepeatedSfixed64()[1]);
75ffe3c632Sopenharmony_ci        $this->assertEquals(2.5,   $m->getRepeatedFloat()[1]);
76ffe3c632Sopenharmony_ci        $this->assertEquals(2.6,   $m->getRepeatedDouble()[1]);
77ffe3c632Sopenharmony_ci        $this->assertEquals(false, $m->getRepeatedBool()[1]);
78ffe3c632Sopenharmony_ci        $this->assertEquals('c',   $m->getRepeatedString()[1]);
79ffe3c632Sopenharmony_ci        $this->assertEquals('dddd',   $m->getRepeatedBytes()[1]);
80ffe3c632Sopenharmony_ci        $this->assertEquals(35,    $m->getRepeatedMessage()[1]->GetA());
81ffe3c632Sopenharmony_ci
82ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
83ffe3c632Sopenharmony_ci            $this->assertEquals('-63', $m->getMapInt64Int64()['-63']);
84ffe3c632Sopenharmony_ci            $this->assertEquals('63',  $m->getMapUint64Uint64()['63']);
85ffe3c632Sopenharmony_ci            $this->assertEquals('-65', $m->getMapSint64Sint64()['-65']);
86ffe3c632Sopenharmony_ci            $this->assertEquals('67',  $m->getMapFixed64Fixed64()['67']);
87ffe3c632Sopenharmony_ci            $this->assertEquals('-69',  $m->getMapSfixed64Sfixed64()['-69']);
88ffe3c632Sopenharmony_ci        } else {
89ffe3c632Sopenharmony_ci            $this->assertEquals(-63, $m->getMapInt64Int64()[-63]);
90ffe3c632Sopenharmony_ci            $this->assertEquals(63,  $m->getMapUint64Uint64()[63]);
91ffe3c632Sopenharmony_ci            $this->assertEquals(-65, $m->getMapSint64Sint64()[-65]);
92ffe3c632Sopenharmony_ci            $this->assertEquals(67,  $m->getMapFixed64Fixed64()[67]);
93ffe3c632Sopenharmony_ci            $this->assertEquals(-69,  $m->getMapSfixed64Sfixed64()[-69]);
94ffe3c632Sopenharmony_ci        }
95ffe3c632Sopenharmony_ci        $this->assertEquals(-62, $m->getMapInt32Int32()[-62]);
96ffe3c632Sopenharmony_ci        $this->assertEquals(62,  $m->getMapUint32Uint32()[62]);
97ffe3c632Sopenharmony_ci        $this->assertEquals(-64, $m->getMapSint32Sint32()[-64]);
98ffe3c632Sopenharmony_ci        $this->assertEquals(66,  $m->getMapFixed32Fixed32()[66]);
99ffe3c632Sopenharmony_ci        $this->assertEquals(-68,  $m->getMapSfixed32Sfixed32()[-68]);
100ffe3c632Sopenharmony_ci        $this->assertEquals(3.5, $m->getMapInt32Float()[1]);
101ffe3c632Sopenharmony_ci        $this->assertEquals(3.6, $m->getMapInt32Double()[1]);
102ffe3c632Sopenharmony_ci        $this->assertEquals(true , $m->getMapBoolBool()[true]);
103ffe3c632Sopenharmony_ci        $this->assertEquals('e', $m->getMapStringString()['e']);
104ffe3c632Sopenharmony_ci        $this->assertEquals('ffff', $m->getMapInt32Bytes()[1]);
105ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE, $m->getMapInt32Enum()[1]);
106ffe3c632Sopenharmony_ci        $this->assertEquals(36, $m->getMapInt32Message()[1]->GetA());
107ffe3c632Sopenharmony_ci    }
108ffe3c632Sopenharmony_ci
109ffe3c632Sopenharmony_ci    // Test message merged from setFields and setFields2.
110ffe3c632Sopenharmony_ci    public function expectFieldsMerged(TestMessage $m)
111ffe3c632Sopenharmony_ci    {
112ffe3c632Sopenharmony_ci        $this->assertSame(-144,  $m->getOptionalSint32());
113ffe3c632Sopenharmony_ci        $this->assertSame(146,   $m->getOptionalFixed32());
114ffe3c632Sopenharmony_ci        $this->assertSame(-146,  $m->getOptionalSfixed32());
115ffe3c632Sopenharmony_ci        $this->assertSame(11.5,  $m->getOptionalFloat());
116ffe3c632Sopenharmony_ci        $this->assertSame(11.6,  $m->getOptionalDouble());
117ffe3c632Sopenharmony_ci        $this->assertSame(true, $m->getOptionalBool());
118ffe3c632Sopenharmony_ci        $this->assertSame('aa',  $m->getOptionalString());
119ffe3c632Sopenharmony_ci        $this->assertSame('bb',  $m->getOptionalBytes());
120ffe3c632Sopenharmony_ci        $this->assertSame(133,   $m->getOptionalMessage()->getA());
121ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
122ffe3c632Sopenharmony_ci            $this->assertSame('-143',  $m->getOptionalInt64());
123ffe3c632Sopenharmony_ci            $this->assertSame('143',   $m->getOptionalUint64());
124ffe3c632Sopenharmony_ci            $this->assertSame('-145',  $m->getOptionalSint64());
125ffe3c632Sopenharmony_ci            $this->assertSame('147',   $m->getOptionalFixed64());
126ffe3c632Sopenharmony_ci            $this->assertSame('-147',  $m->getOptionalSfixed64());
127ffe3c632Sopenharmony_ci        } else {
128ffe3c632Sopenharmony_ci            $this->assertSame(-143,  $m->getOptionalInt64());
129ffe3c632Sopenharmony_ci            $this->assertSame(143,   $m->getOptionalUint64());
130ffe3c632Sopenharmony_ci            $this->assertSame(-145,  $m->getOptionalSint64());
131ffe3c632Sopenharmony_ci            $this->assertSame(147,   $m->getOptionalFixed64());
132ffe3c632Sopenharmony_ci            $this->assertSame(-147,  $m->getOptionalSfixed64());
133ffe3c632Sopenharmony_ci        }
134ffe3c632Sopenharmony_ci
135ffe3c632Sopenharmony_ci        $this->assertEquals(-42,  $m->getRepeatedInt32()[0]);
136ffe3c632Sopenharmony_ci        $this->assertEquals(42,   $m->getRepeatedUint32()[0]);
137ffe3c632Sopenharmony_ci        $this->assertEquals(-43,  $m->getRepeatedInt64()[0]);
138ffe3c632Sopenharmony_ci        $this->assertEquals(43,   $m->getRepeatedUint64()[0]);
139ffe3c632Sopenharmony_ci        $this->assertEquals(-44,  $m->getRepeatedSint32()[0]);
140ffe3c632Sopenharmony_ci        $this->assertEquals(-45,  $m->getRepeatedSint64()[0]);
141ffe3c632Sopenharmony_ci        $this->assertEquals(46,   $m->getRepeatedFixed32()[0]);
142ffe3c632Sopenharmony_ci        $this->assertEquals(47,   $m->getRepeatedFixed64()[0]);
143ffe3c632Sopenharmony_ci        $this->assertEquals(-46,  $m->getRepeatedSfixed32()[0]);
144ffe3c632Sopenharmony_ci        $this->assertEquals(-47,  $m->getRepeatedSfixed64()[0]);
145ffe3c632Sopenharmony_ci        $this->assertEquals(1.5,  $m->getRepeatedFloat()[0]);
146ffe3c632Sopenharmony_ci        $this->assertEquals(1.6,  $m->getRepeatedDouble()[0]);
147ffe3c632Sopenharmony_ci        $this->assertEquals(true, $m->getRepeatedBool()[0]);
148ffe3c632Sopenharmony_ci        $this->assertEquals('a',  $m->getRepeatedString()[0]);
149ffe3c632Sopenharmony_ci        $this->assertEquals('bbbb',  $m->getRepeatedBytes()[0]);
150ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ZERO,  $m->getRepeatedEnum()[0]);
151ffe3c632Sopenharmony_ci        $this->assertEquals(34,   $m->getRepeatedMessage()[0]->GetA());
152ffe3c632Sopenharmony_ci
153ffe3c632Sopenharmony_ci        $this->assertEquals(-52,   $m->getRepeatedInt32()[1]);
154ffe3c632Sopenharmony_ci        $this->assertEquals(52,    $m->getRepeatedUint32()[1]);
155ffe3c632Sopenharmony_ci        $this->assertEquals(-53,   $m->getRepeatedInt64()[1]);
156ffe3c632Sopenharmony_ci        $this->assertEquals(53,    $m->getRepeatedUint64()[1]);
157ffe3c632Sopenharmony_ci        $this->assertEquals(-54,   $m->getRepeatedSint32()[1]);
158ffe3c632Sopenharmony_ci        $this->assertEquals(-55,   $m->getRepeatedSint64()[1]);
159ffe3c632Sopenharmony_ci        $this->assertEquals(56,    $m->getRepeatedFixed32()[1]);
160ffe3c632Sopenharmony_ci        $this->assertEquals(57,    $m->getRepeatedFixed64()[1]);
161ffe3c632Sopenharmony_ci        $this->assertEquals(-56,   $m->getRepeatedSfixed32()[1]);
162ffe3c632Sopenharmony_ci        $this->assertEquals(-57,   $m->getRepeatedSfixed64()[1]);
163ffe3c632Sopenharmony_ci        $this->assertEquals(2.5,   $m->getRepeatedFloat()[1]);
164ffe3c632Sopenharmony_ci        $this->assertEquals(2.6,   $m->getRepeatedDouble()[1]);
165ffe3c632Sopenharmony_ci        $this->assertEquals(false, $m->getRepeatedBool()[1]);
166ffe3c632Sopenharmony_ci        $this->assertEquals('c',   $m->getRepeatedString()[1]);
167ffe3c632Sopenharmony_ci        $this->assertEquals('dddd',   $m->getRepeatedBytes()[1]);
168ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE,  $m->getRepeatedEnum()[1]);
169ffe3c632Sopenharmony_ci        $this->assertEquals(35,    $m->getRepeatedMessage()[1]->GetA());
170ffe3c632Sopenharmony_ci
171ffe3c632Sopenharmony_ci        $this->assertEquals(-142,  $m->getRepeatedInt32()[2]);
172ffe3c632Sopenharmony_ci        $this->assertEquals(142,   $m->getRepeatedUint32()[2]);
173ffe3c632Sopenharmony_ci        $this->assertEquals(-143,  $m->getRepeatedInt64()[2]);
174ffe3c632Sopenharmony_ci        $this->assertEquals(143,   $m->getRepeatedUint64()[2]);
175ffe3c632Sopenharmony_ci        $this->assertEquals(-144,  $m->getRepeatedSint32()[2]);
176ffe3c632Sopenharmony_ci        $this->assertEquals(-145,  $m->getRepeatedSint64()[2]);
177ffe3c632Sopenharmony_ci        $this->assertEquals(146,   $m->getRepeatedFixed32()[2]);
178ffe3c632Sopenharmony_ci        $this->assertEquals(147,   $m->getRepeatedFixed64()[2]);
179ffe3c632Sopenharmony_ci        $this->assertEquals(-146,  $m->getRepeatedSfixed32()[2]);
180ffe3c632Sopenharmony_ci        $this->assertEquals(-147,  $m->getRepeatedSfixed64()[2]);
181ffe3c632Sopenharmony_ci        $this->assertEquals(11.5,  $m->getRepeatedFloat()[2]);
182ffe3c632Sopenharmony_ci        $this->assertEquals(11.6,  $m->getRepeatedDouble()[2]);
183ffe3c632Sopenharmony_ci        $this->assertEquals(false, $m->getRepeatedBool()[2]);
184ffe3c632Sopenharmony_ci        $this->assertEquals('aa',  $m->getRepeatedString()[2]);
185ffe3c632Sopenharmony_ci        $this->assertEquals('bb',  $m->getRepeatedBytes()[2]);
186ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::TWO,  $m->getRepeatedEnum()[2]);
187ffe3c632Sopenharmony_ci        $this->assertEquals(134,   $m->getRepeatedMessage()[2]->GetA());
188ffe3c632Sopenharmony_ci
189ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
190ffe3c632Sopenharmony_ci            $this->assertEquals('-163', $m->getMapInt64Int64()['-63']);
191ffe3c632Sopenharmony_ci            $this->assertEquals('163',  $m->getMapUint64Uint64()['63']);
192ffe3c632Sopenharmony_ci            $this->assertEquals('-165', $m->getMapSint64Sint64()['-65']);
193ffe3c632Sopenharmony_ci            $this->assertEquals('167',  $m->getMapFixed64Fixed64()['67']);
194ffe3c632Sopenharmony_ci            $this->assertEquals('-169',  $m->getMapSfixed64Sfixed64()['-69']);
195ffe3c632Sopenharmony_ci        } else {
196ffe3c632Sopenharmony_ci            $this->assertEquals(-163, $m->getMapInt64Int64()[-63]);
197ffe3c632Sopenharmony_ci            $this->assertEquals(163,  $m->getMapUint64Uint64()[63]);
198ffe3c632Sopenharmony_ci            $this->assertEquals(-165, $m->getMapSint64Sint64()[-65]);
199ffe3c632Sopenharmony_ci            $this->assertEquals(167,  $m->getMapFixed64Fixed64()[67]);
200ffe3c632Sopenharmony_ci            $this->assertEquals(-169,  $m->getMapSfixed64Sfixed64()[-69]);
201ffe3c632Sopenharmony_ci        }
202ffe3c632Sopenharmony_ci        $this->assertEquals(-162, $m->getMapInt32Int32()[-62]);
203ffe3c632Sopenharmony_ci        $this->assertEquals(162,  $m->getMapUint32Uint32()[62]);
204ffe3c632Sopenharmony_ci        $this->assertEquals(-164, $m->getMapSint32Sint32()[-64]);
205ffe3c632Sopenharmony_ci        $this->assertEquals(166,  $m->getMapFixed32Fixed32()[66]);
206ffe3c632Sopenharmony_ci        $this->assertEquals(-168,  $m->getMapSfixed32Sfixed32()[-68]);
207ffe3c632Sopenharmony_ci        $this->assertEquals(13.5, $m->getMapInt32Float()[1]);
208ffe3c632Sopenharmony_ci        $this->assertEquals(13.6, $m->getMapInt32Double()[1]);
209ffe3c632Sopenharmony_ci        $this->assertEquals(false , $m->getMapBoolBool()[true]);
210ffe3c632Sopenharmony_ci        $this->assertEquals('ee', $m->getMapStringString()['e']);
211ffe3c632Sopenharmony_ci        $this->assertEquals('ff', $m->getMapInt32Bytes()[1]);
212ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[1]);
213ffe3c632Sopenharmony_ci        $this->assertEquals(136, $m->getMapInt32Message()[1]->GetA());
214ffe3c632Sopenharmony_ci
215ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
216ffe3c632Sopenharmony_ci            $this->assertEquals('-163', $m->getMapInt64Int64()['-163']);
217ffe3c632Sopenharmony_ci            $this->assertEquals('163',  $m->getMapUint64Uint64()['163']);
218ffe3c632Sopenharmony_ci            $this->assertEquals('-165', $m->getMapSint64Sint64()['-165']);
219ffe3c632Sopenharmony_ci            $this->assertEquals('167',  $m->getMapFixed64Fixed64()['167']);
220ffe3c632Sopenharmony_ci            $this->assertEquals('-169',  $m->getMapSfixed64Sfixed64()['-169']);
221ffe3c632Sopenharmony_ci        } else {
222ffe3c632Sopenharmony_ci            $this->assertEquals(-163, $m->getMapInt64Int64()[-163]);
223ffe3c632Sopenharmony_ci            $this->assertEquals(163,  $m->getMapUint64Uint64()[163]);
224ffe3c632Sopenharmony_ci            $this->assertEquals(-165, $m->getMapSint64Sint64()[-165]);
225ffe3c632Sopenharmony_ci            $this->assertEquals(167,  $m->getMapFixed64Fixed64()[167]);
226ffe3c632Sopenharmony_ci            $this->assertEquals(-169,  $m->getMapSfixed64Sfixed64()[-169]);
227ffe3c632Sopenharmony_ci        }
228ffe3c632Sopenharmony_ci        $this->assertEquals(-162, $m->getMapInt32Int32()[-162]);
229ffe3c632Sopenharmony_ci        $this->assertEquals(162,  $m->getMapUint32Uint32()[162]);
230ffe3c632Sopenharmony_ci        $this->assertEquals(-164, $m->getMapSint32Sint32()[-164]);
231ffe3c632Sopenharmony_ci        $this->assertEquals(166,  $m->getMapFixed32Fixed32()[166]);
232ffe3c632Sopenharmony_ci        $this->assertEquals(-168,  $m->getMapSfixed32Sfixed32()[-168]);
233ffe3c632Sopenharmony_ci        $this->assertEquals(13.5, $m->getMapInt32Float()[2]);
234ffe3c632Sopenharmony_ci        $this->assertEquals(13.6, $m->getMapInt32Double()[2]);
235ffe3c632Sopenharmony_ci        $this->assertEquals(false , $m->getMapBoolBool()[false]);
236ffe3c632Sopenharmony_ci        $this->assertEquals('ee', $m->getMapStringString()['ee']);
237ffe3c632Sopenharmony_ci        $this->assertEquals('ff', $m->getMapInt32Bytes()[2]);
238ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::TWO, $m->getMapInt32Enum()[2]);
239ffe3c632Sopenharmony_ci        $this->assertEquals(136, $m->getMapInt32Message()[2]->GetA());
240ffe3c632Sopenharmony_ci    }
241ffe3c632Sopenharmony_ci
242ffe3c632Sopenharmony_ci    public function expectEmptyFields(TestMessage $m)
243ffe3c632Sopenharmony_ci    {
244ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOptionalInt32());
245ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOptionalUint32());
246ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOptionalSint32());
247ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOptionalFixed32());
248ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOptionalSfixed32());
249ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOptionalFloat());
250ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOptionalDouble());
251ffe3c632Sopenharmony_ci        $this->assertSame(false, $m->getOptionalBool());
252ffe3c632Sopenharmony_ci        $this->assertSame('',  $m->getOptionalString());
253ffe3c632Sopenharmony_ci        $this->assertSame('',  $m->getOptionalBytes());
254ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getOptionalEnum());
255ffe3c632Sopenharmony_ci        $this->assertNull($m->getOptionalMessage());
256ffe3c632Sopenharmony_ci        $this->assertNull($m->getOptionalIncludedMessage());
257ffe3c632Sopenharmony_ci        $this->assertNull($m->getRecursive());
258ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
259ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOptionalInt64());
260ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOptionalUint64());
261ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOptionalSint64());
262ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOptionalFixed64());
263ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOptionalSfixed64());
264ffe3c632Sopenharmony_ci        } else {
265ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOptionalInt64());
266ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOptionalUint64());
267ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOptionalSint64());
268ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOptionalFixed64());
269ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOptionalSfixed64());
270ffe3c632Sopenharmony_ci        }
271ffe3c632Sopenharmony_ci
272ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedInt32()));
273ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedUint32()));
274ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedInt64()));
275ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedUint64()));
276ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedSint32()));
277ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedSint64()));
278ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedFixed32()));
279ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedFixed64()));
280ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedSfixed32()));
281ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedSfixed64()));
282ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedFloat()));
283ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedDouble()));
284ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedBool()));
285ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedString()));
286ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedBytes()));
287ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedEnum()));
288ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedMessage()));
289ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getRepeatedRecursive()));
290ffe3c632Sopenharmony_ci
291ffe3c632Sopenharmony_ci        $this->assertSame("", $m->getMyOneof());
292ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOneofInt32());
293ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOneofUint32());
294ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOneofSint32());
295ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOneofFixed32());
296ffe3c632Sopenharmony_ci        $this->assertSame(0,   $m->getOneofSfixed32());
297ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOneofFloat());
298ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOneofDouble());
299ffe3c632Sopenharmony_ci        $this->assertSame(false, $m->getOneofBool());
300ffe3c632Sopenharmony_ci        $this->assertSame('',  $m->getOneofString());
301ffe3c632Sopenharmony_ci        $this->assertSame('',  $m->getOneofBytes());
302ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getOneofEnum());
303ffe3c632Sopenharmony_ci        $this->assertNull($m->getOptionalMessage());
304ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
305ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOneofInt64());
306ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOneofUint64());
307ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOneofSint64());
308ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOneofFixed64());
309ffe3c632Sopenharmony_ci            $this->assertSame("0", $m->getOneofSfixed64());
310ffe3c632Sopenharmony_ci        } else {
311ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOneofInt64());
312ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOneofUint64());
313ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOneofSint64());
314ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOneofFixed64());
315ffe3c632Sopenharmony_ci            $this->assertSame(0, $m->getOneofSfixed64());
316ffe3c632Sopenharmony_ci        }
317ffe3c632Sopenharmony_ci
318ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt64Int64()));
319ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapUint64Uint64()));
320ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapSint64Sint64()));
321ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapFixed64Fixed64()));
322ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Int32()));
323ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapUint32Uint32()));
324ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapSint32Sint32()));
325ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapFixed32Fixed32()));
326ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapSfixed32Sfixed32()));
327ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapSfixed64Sfixed64()));
328ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Float()));
329ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Double()));
330ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapBoolBool()));
331ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapStringString()));
332ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Bytes()));
333ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Enum()));
334ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapInt32Message()));
335ffe3c632Sopenharmony_ci        $this->assertEquals(0, count($m->getMapRecursive()));
336ffe3c632Sopenharmony_ci    }
337ffe3c632Sopenharmony_ci
338ffe3c632Sopenharmony_ci  // This test is to avoid the warning of no test by php unit.
339ffe3c632Sopenharmony_ci  public function testNone()
340ffe3c632Sopenharmony_ci  {
341ffe3c632Sopenharmony_ci      $this->assertTrue(true);
342ffe3c632Sopenharmony_ci  }
343ffe3c632Sopenharmony_ci}
344