1ffe3c632Sopenharmony_ci<?php 2ffe3c632Sopenharmony_ci 3ffe3c632Sopenharmony_cirequire_once('test_util.php'); 4ffe3c632Sopenharmony_ci 5ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\RepeatedField; 6ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\GPBType; 7ffe3c632Sopenharmony_ciuse Foo\TestMessage; 8ffe3c632Sopenharmony_ciuse Foo\TestMessage\Sub; 9ffe3c632Sopenharmony_ci 10ffe3c632Sopenharmony_ciclass UndefinedTest extends PHPUnit_Framework_TestCase 11ffe3c632Sopenharmony_ci{ 12ffe3c632Sopenharmony_ci 13ffe3c632Sopenharmony_ci /** 14ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 15ffe3c632Sopenharmony_ci */ 16ffe3c632Sopenharmony_ci public function testInt32AppendStringFail() 17ffe3c632Sopenharmony_ci { 18ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 19ffe3c632Sopenharmony_ci $arr[] = 'abc'; 20ffe3c632Sopenharmony_ci } 21ffe3c632Sopenharmony_ci 22ffe3c632Sopenharmony_ci /** 23ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 24ffe3c632Sopenharmony_ci */ 25ffe3c632Sopenharmony_ci public function testInt32SetStringFail() 26ffe3c632Sopenharmony_ci { 27ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 28ffe3c632Sopenharmony_ci $arr[] = 0; 29ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 30ffe3c632Sopenharmony_ci } 31ffe3c632Sopenharmony_ci 32ffe3c632Sopenharmony_ci /** 33ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 34ffe3c632Sopenharmony_ci */ 35ffe3c632Sopenharmony_ci public function testInt32AppendMessageFail() 36ffe3c632Sopenharmony_ci { 37ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 38ffe3c632Sopenharmony_ci $arr[] = new Sub(); 39ffe3c632Sopenharmony_ci } 40ffe3c632Sopenharmony_ci 41ffe3c632Sopenharmony_ci /** 42ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 43ffe3c632Sopenharmony_ci */ 44ffe3c632Sopenharmony_ci public function testInt32SetMessageFail() 45ffe3c632Sopenharmony_ci { 46ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 47ffe3c632Sopenharmony_ci $arr[] = 0; 48ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 49ffe3c632Sopenharmony_ci } 50ffe3c632Sopenharmony_ci 51ffe3c632Sopenharmony_ci /** 52ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 53ffe3c632Sopenharmony_ci */ 54ffe3c632Sopenharmony_ci public function testUint32AppendStringFail() 55ffe3c632Sopenharmony_ci { 56ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT32); 57ffe3c632Sopenharmony_ci $arr[] = 'abc'; 58ffe3c632Sopenharmony_ci } 59ffe3c632Sopenharmony_ci 60ffe3c632Sopenharmony_ci /** 61ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 62ffe3c632Sopenharmony_ci */ 63ffe3c632Sopenharmony_ci public function testUint32SetStringFail() 64ffe3c632Sopenharmony_ci { 65ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT32); 66ffe3c632Sopenharmony_ci $arr[] = 0; 67ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 68ffe3c632Sopenharmony_ci } 69ffe3c632Sopenharmony_ci 70ffe3c632Sopenharmony_ci /** 71ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 72ffe3c632Sopenharmony_ci */ 73ffe3c632Sopenharmony_ci public function testUint32AppendMessageFail() 74ffe3c632Sopenharmony_ci { 75ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT32); 76ffe3c632Sopenharmony_ci $arr[] = new Sub(); 77ffe3c632Sopenharmony_ci } 78ffe3c632Sopenharmony_ci 79ffe3c632Sopenharmony_ci /** 80ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 81ffe3c632Sopenharmony_ci */ 82ffe3c632Sopenharmony_ci public function testUint32SetMessageFail() 83ffe3c632Sopenharmony_ci { 84ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT32); 85ffe3c632Sopenharmony_ci $arr[] = 0; 86ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 87ffe3c632Sopenharmony_ci } 88ffe3c632Sopenharmony_ci 89ffe3c632Sopenharmony_ci /** 90ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 91ffe3c632Sopenharmony_ci */ 92ffe3c632Sopenharmony_ci public function testInt64AppendStringFail() 93ffe3c632Sopenharmony_ci { 94ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT64); 95ffe3c632Sopenharmony_ci $arr[] = 'abc'; 96ffe3c632Sopenharmony_ci } 97ffe3c632Sopenharmony_ci 98ffe3c632Sopenharmony_ci /** 99ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 100ffe3c632Sopenharmony_ci */ 101ffe3c632Sopenharmony_ci public function testInt64SetStringFail() 102ffe3c632Sopenharmony_ci { 103ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT64); 104ffe3c632Sopenharmony_ci $arr[] = 0; 105ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 106ffe3c632Sopenharmony_ci } 107ffe3c632Sopenharmony_ci 108ffe3c632Sopenharmony_ci /** 109ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 110ffe3c632Sopenharmony_ci */ 111ffe3c632Sopenharmony_ci public function testInt64AppendMessageFail() 112ffe3c632Sopenharmony_ci { 113ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT64); 114ffe3c632Sopenharmony_ci $arr[] = new Sub(); 115ffe3c632Sopenharmony_ci } 116ffe3c632Sopenharmony_ci 117ffe3c632Sopenharmony_ci /** 118ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 119ffe3c632Sopenharmony_ci */ 120ffe3c632Sopenharmony_ci public function testInt64SetMessageFail() 121ffe3c632Sopenharmony_ci { 122ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT64); 123ffe3c632Sopenharmony_ci $arr[] = 0; 124ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 125ffe3c632Sopenharmony_ci } 126ffe3c632Sopenharmony_ci 127ffe3c632Sopenharmony_ci /** 128ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 129ffe3c632Sopenharmony_ci */ 130ffe3c632Sopenharmony_ci public function testUint64AppendStringFail() 131ffe3c632Sopenharmony_ci { 132ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT64); 133ffe3c632Sopenharmony_ci $arr[] = 'abc'; 134ffe3c632Sopenharmony_ci } 135ffe3c632Sopenharmony_ci 136ffe3c632Sopenharmony_ci /** 137ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 138ffe3c632Sopenharmony_ci */ 139ffe3c632Sopenharmony_ci public function testUint64SetStringFail() 140ffe3c632Sopenharmony_ci { 141ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT64); 142ffe3c632Sopenharmony_ci $arr[] = 0; 143ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 144ffe3c632Sopenharmony_ci } 145ffe3c632Sopenharmony_ci 146ffe3c632Sopenharmony_ci /** 147ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 148ffe3c632Sopenharmony_ci */ 149ffe3c632Sopenharmony_ci public function testUint64AppendMessageFail() 150ffe3c632Sopenharmony_ci { 151ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT64); 152ffe3c632Sopenharmony_ci $arr[] = new Sub(); 153ffe3c632Sopenharmony_ci } 154ffe3c632Sopenharmony_ci 155ffe3c632Sopenharmony_ci /** 156ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 157ffe3c632Sopenharmony_ci */ 158ffe3c632Sopenharmony_ci public function testUint64SetMessageFail() 159ffe3c632Sopenharmony_ci { 160ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::UINT64); 161ffe3c632Sopenharmony_ci $arr[] = 0; 162ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 163ffe3c632Sopenharmony_ci } 164ffe3c632Sopenharmony_ci 165ffe3c632Sopenharmony_ci /** 166ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 167ffe3c632Sopenharmony_ci */ 168ffe3c632Sopenharmony_ci public function testFloatAppendStringFail() 169ffe3c632Sopenharmony_ci { 170ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::FLOAT); 171ffe3c632Sopenharmony_ci $arr[] = 'abc'; 172ffe3c632Sopenharmony_ci } 173ffe3c632Sopenharmony_ci 174ffe3c632Sopenharmony_ci /** 175ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 176ffe3c632Sopenharmony_ci */ 177ffe3c632Sopenharmony_ci public function testFloatSetStringFail() 178ffe3c632Sopenharmony_ci { 179ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::FLOAT); 180ffe3c632Sopenharmony_ci $arr[] = 0.0; 181ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 182ffe3c632Sopenharmony_ci } 183ffe3c632Sopenharmony_ci 184ffe3c632Sopenharmony_ci /** 185ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 186ffe3c632Sopenharmony_ci */ 187ffe3c632Sopenharmony_ci public function testFloatAppendMessageFail() 188ffe3c632Sopenharmony_ci { 189ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::FLOAT); 190ffe3c632Sopenharmony_ci $arr[] = new Sub(); 191ffe3c632Sopenharmony_ci } 192ffe3c632Sopenharmony_ci 193ffe3c632Sopenharmony_ci /** 194ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 195ffe3c632Sopenharmony_ci */ 196ffe3c632Sopenharmony_ci public function testFloatSetMessageFail() 197ffe3c632Sopenharmony_ci { 198ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::FLOAT); 199ffe3c632Sopenharmony_ci $arr[] = 0.0; 200ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 201ffe3c632Sopenharmony_ci } 202ffe3c632Sopenharmony_ci 203ffe3c632Sopenharmony_ci /** 204ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 205ffe3c632Sopenharmony_ci */ 206ffe3c632Sopenharmony_ci public function testDoubleAppendStringFail() 207ffe3c632Sopenharmony_ci { 208ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::DOUBLE); 209ffe3c632Sopenharmony_ci $arr[] = 'abc'; 210ffe3c632Sopenharmony_ci } 211ffe3c632Sopenharmony_ci 212ffe3c632Sopenharmony_ci /** 213ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 214ffe3c632Sopenharmony_ci */ 215ffe3c632Sopenharmony_ci public function testDoubleSetStringFail() 216ffe3c632Sopenharmony_ci { 217ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::DOUBLE); 218ffe3c632Sopenharmony_ci $arr[] = 0.0; 219ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 220ffe3c632Sopenharmony_ci } 221ffe3c632Sopenharmony_ci 222ffe3c632Sopenharmony_ci /** 223ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 224ffe3c632Sopenharmony_ci */ 225ffe3c632Sopenharmony_ci public function testDoubleAppendMessageFail() 226ffe3c632Sopenharmony_ci { 227ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::DOUBLE); 228ffe3c632Sopenharmony_ci $arr[] = new Sub(); 229ffe3c632Sopenharmony_ci } 230ffe3c632Sopenharmony_ci 231ffe3c632Sopenharmony_ci /** 232ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 233ffe3c632Sopenharmony_ci */ 234ffe3c632Sopenharmony_ci public function testDoubleSetMessageFail() 235ffe3c632Sopenharmony_ci { 236ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::DOUBLE); 237ffe3c632Sopenharmony_ci $arr[] = 0.0; 238ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 239ffe3c632Sopenharmony_ci } 240ffe3c632Sopenharmony_ci 241ffe3c632Sopenharmony_ci /** 242ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 243ffe3c632Sopenharmony_ci */ 244ffe3c632Sopenharmony_ci public function testBoolAppendMessageFail() 245ffe3c632Sopenharmony_ci { 246ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::BOOL); 247ffe3c632Sopenharmony_ci $arr[] = new Sub(); 248ffe3c632Sopenharmony_ci } 249ffe3c632Sopenharmony_ci 250ffe3c632Sopenharmony_ci /** 251ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 252ffe3c632Sopenharmony_ci */ 253ffe3c632Sopenharmony_ci public function testBoolSetMessageFail() 254ffe3c632Sopenharmony_ci { 255ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::BOOL); 256ffe3c632Sopenharmony_ci $arr[] = true; 257ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 258ffe3c632Sopenharmony_ci } 259ffe3c632Sopenharmony_ci 260ffe3c632Sopenharmony_ci /** 261ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 262ffe3c632Sopenharmony_ci */ 263ffe3c632Sopenharmony_ci public function testStringAppendMessageFail() 264ffe3c632Sopenharmony_ci { 265ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::STRING); 266ffe3c632Sopenharmony_ci $arr[] = new Sub(); 267ffe3c632Sopenharmony_ci } 268ffe3c632Sopenharmony_ci 269ffe3c632Sopenharmony_ci /** 270ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 271ffe3c632Sopenharmony_ci */ 272ffe3c632Sopenharmony_ci public function testStringSetMessageFail() 273ffe3c632Sopenharmony_ci { 274ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::STRING); 275ffe3c632Sopenharmony_ci $arr[] = 'abc'; 276ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 277ffe3c632Sopenharmony_ci } 278ffe3c632Sopenharmony_ci 279ffe3c632Sopenharmony_ci /** 280ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 281ffe3c632Sopenharmony_ci */ 282ffe3c632Sopenharmony_ci public function testStringAppendInvalidUTF8Fail() 283ffe3c632Sopenharmony_ci { 284ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::STRING); 285ffe3c632Sopenharmony_ci $hex = hex2bin("ff"); 286ffe3c632Sopenharmony_ci $arr[] = $hex; 287ffe3c632Sopenharmony_ci } 288ffe3c632Sopenharmony_ci 289ffe3c632Sopenharmony_ci /** 290ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 291ffe3c632Sopenharmony_ci */ 292ffe3c632Sopenharmony_ci public function testStringSetInvalidUTF8Fail() 293ffe3c632Sopenharmony_ci { 294ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::STRING); 295ffe3c632Sopenharmony_ci $arr[] = 'abc'; 296ffe3c632Sopenharmony_ci $hex = hex2bin("ff"); 297ffe3c632Sopenharmony_ci $arr[0] = $hex; 298ffe3c632Sopenharmony_ci } 299ffe3c632Sopenharmony_ci 300ffe3c632Sopenharmony_ci /** 301ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 302ffe3c632Sopenharmony_ci */ 303ffe3c632Sopenharmony_ci public function testMessageAppendIntFail() 304ffe3c632Sopenharmony_ci { 305ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 306ffe3c632Sopenharmony_ci $arr[] = 1; 307ffe3c632Sopenharmony_ci } 308ffe3c632Sopenharmony_ci 309ffe3c632Sopenharmony_ci /** 310ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 311ffe3c632Sopenharmony_ci */ 312ffe3c632Sopenharmony_ci public function testMessageSetIntFail() 313ffe3c632Sopenharmony_ci { 314ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 315ffe3c632Sopenharmony_ci $arr[] = new Sub; 316ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 317ffe3c632Sopenharmony_ci } 318ffe3c632Sopenharmony_ci 319ffe3c632Sopenharmony_ci /** 320ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 321ffe3c632Sopenharmony_ci */ 322ffe3c632Sopenharmony_ci public function testMessageAppendStringFail() 323ffe3c632Sopenharmony_ci { 324ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 325ffe3c632Sopenharmony_ci $arr[] = 'abc'; 326ffe3c632Sopenharmony_ci } 327ffe3c632Sopenharmony_ci 328ffe3c632Sopenharmony_ci /** 329ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 330ffe3c632Sopenharmony_ci */ 331ffe3c632Sopenharmony_ci public function testMessageSetStringFail() 332ffe3c632Sopenharmony_ci { 333ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 334ffe3c632Sopenharmony_ci $arr[] = new Sub; 335ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 336ffe3c632Sopenharmony_ci } 337ffe3c632Sopenharmony_ci 338ffe3c632Sopenharmony_ci /** 339ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 340ffe3c632Sopenharmony_ci */ 341ffe3c632Sopenharmony_ci public function testMessageAppendOtherMessageFail() 342ffe3c632Sopenharmony_ci { 343ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 344ffe3c632Sopenharmony_ci $arr[] = new TestMessage; 345ffe3c632Sopenharmony_ci } 346ffe3c632Sopenharmony_ci 347ffe3c632Sopenharmony_ci /** 348ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 349ffe3c632Sopenharmony_ci */ 350ffe3c632Sopenharmony_ci public function testMessageAppendNullFail() 351ffe3c632Sopenharmony_ci { 352ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 353ffe3c632Sopenharmony_ci $null = null; 354ffe3c632Sopenharmony_ci $arr[] = $null; 355ffe3c632Sopenharmony_ci } 356ffe3c632Sopenharmony_ci 357ffe3c632Sopenharmony_ci /** 358ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 359ffe3c632Sopenharmony_ci */ 360ffe3c632Sopenharmony_ci public function testMessageSetNullFail() 361ffe3c632Sopenharmony_ci { 362ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::MESSAGE, Sub::class); 363ffe3c632Sopenharmony_ci $arr[] = new Sub(); 364ffe3c632Sopenharmony_ci $null = null; 365ffe3c632Sopenharmony_ci $arr[0] = $null; 366ffe3c632Sopenharmony_ci } 367ffe3c632Sopenharmony_ci 368ffe3c632Sopenharmony_ci /** 369ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 370ffe3c632Sopenharmony_ci */ 371ffe3c632Sopenharmony_ci public function testRemoveMiddleFail() 372ffe3c632Sopenharmony_ci { 373ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 374ffe3c632Sopenharmony_ci 375ffe3c632Sopenharmony_ci $arr[] = 0; 376ffe3c632Sopenharmony_ci $arr[] = 1; 377ffe3c632Sopenharmony_ci $arr[] = 2; 378ffe3c632Sopenharmony_ci $this->assertSame(3, count($arr)); 379ffe3c632Sopenharmony_ci 380ffe3c632Sopenharmony_ci unset($arr[1]); 381ffe3c632Sopenharmony_ci } 382ffe3c632Sopenharmony_ci 383ffe3c632Sopenharmony_ci /** 384ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 385ffe3c632Sopenharmony_ci */ 386ffe3c632Sopenharmony_ci public function testRemoveEmptyFail() 387ffe3c632Sopenharmony_ci { 388ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 389ffe3c632Sopenharmony_ci 390ffe3c632Sopenharmony_ci unset($arr[0]); 391ffe3c632Sopenharmony_ci } 392ffe3c632Sopenharmony_ci 393ffe3c632Sopenharmony_ci /** 394ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 395ffe3c632Sopenharmony_ci */ 396ffe3c632Sopenharmony_ci public function testMessageOffsetFail() 397ffe3c632Sopenharmony_ci { 398ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 399ffe3c632Sopenharmony_ci $arr[] = 0; 400ffe3c632Sopenharmony_ci $arr[new Sub()] = 0; 401ffe3c632Sopenharmony_ci } 402ffe3c632Sopenharmony_ci 403ffe3c632Sopenharmony_ci /** 404ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 405ffe3c632Sopenharmony_ci */ 406ffe3c632Sopenharmony_ci public function testStringOffsetFail() 407ffe3c632Sopenharmony_ci { 408ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 409ffe3c632Sopenharmony_ci $arr[] = 0; 410ffe3c632Sopenharmony_ci $arr['abc'] = 0; 411ffe3c632Sopenharmony_ci } 412ffe3c632Sopenharmony_ci 413ffe3c632Sopenharmony_ci /** 414ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 415ffe3c632Sopenharmony_ci */ 416ffe3c632Sopenharmony_ci public function testSetNonExistedOffsetFail() 417ffe3c632Sopenharmony_ci { 418ffe3c632Sopenharmony_ci $arr = new RepeatedField(GPBType::INT32); 419ffe3c632Sopenharmony_ci $arr[0] = 0; 420ffe3c632Sopenharmony_ci } 421ffe3c632Sopenharmony_ci 422ffe3c632Sopenharmony_ci /** 423ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 424ffe3c632Sopenharmony_ci */ 425ffe3c632Sopenharmony_ci public function testInt32FieldInvalidTypeFail() 426ffe3c632Sopenharmony_ci { 427ffe3c632Sopenharmony_ci $m = new TestMessage(); 428ffe3c632Sopenharmony_ci $m->setOptionalInt32(new TestMessage()); 429ffe3c632Sopenharmony_ci } 430ffe3c632Sopenharmony_ci 431ffe3c632Sopenharmony_ci /** 432ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 433ffe3c632Sopenharmony_ci */ 434ffe3c632Sopenharmony_ci public function testInt32FieldInvalidStringFail() 435ffe3c632Sopenharmony_ci { 436ffe3c632Sopenharmony_ci $m = new TestMessage(); 437ffe3c632Sopenharmony_ci $m->setOptionalInt32('abc'); 438ffe3c632Sopenharmony_ci } 439ffe3c632Sopenharmony_ci 440ffe3c632Sopenharmony_ci /** 441ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 442ffe3c632Sopenharmony_ci */ 443ffe3c632Sopenharmony_ci public function testUint32FieldInvalidTypeFail() 444ffe3c632Sopenharmony_ci { 445ffe3c632Sopenharmony_ci $m = new TestMessage(); 446ffe3c632Sopenharmony_ci $m->setOptionalUint32(new TestMessage()); 447ffe3c632Sopenharmony_ci } 448ffe3c632Sopenharmony_ci 449ffe3c632Sopenharmony_ci /** 450ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 451ffe3c632Sopenharmony_ci */ 452ffe3c632Sopenharmony_ci public function testUint32FieldInvalidStringFail() 453ffe3c632Sopenharmony_ci { 454ffe3c632Sopenharmony_ci $m = new TestMessage(); 455ffe3c632Sopenharmony_ci $m->setOptionalUint32('abc'); 456ffe3c632Sopenharmony_ci } 457ffe3c632Sopenharmony_ci 458ffe3c632Sopenharmony_ci /** 459ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 460ffe3c632Sopenharmony_ci */ 461ffe3c632Sopenharmony_ci public function testInt64FieldInvalidTypeFail() 462ffe3c632Sopenharmony_ci { 463ffe3c632Sopenharmony_ci $m = new TestMessage(); 464ffe3c632Sopenharmony_ci $m->setOptionalInt64(new TestMessage()); 465ffe3c632Sopenharmony_ci } 466ffe3c632Sopenharmony_ci 467ffe3c632Sopenharmony_ci /** 468ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 469ffe3c632Sopenharmony_ci */ 470ffe3c632Sopenharmony_ci public function testInt64FieldInvalidStringFail() 471ffe3c632Sopenharmony_ci { 472ffe3c632Sopenharmony_ci $m = new TestMessage(); 473ffe3c632Sopenharmony_ci $m->setOptionalInt64('abc'); 474ffe3c632Sopenharmony_ci } 475ffe3c632Sopenharmony_ci 476ffe3c632Sopenharmony_ci /** 477ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 478ffe3c632Sopenharmony_ci */ 479ffe3c632Sopenharmony_ci public function testUint64FieldInvalidTypeFail() 480ffe3c632Sopenharmony_ci { 481ffe3c632Sopenharmony_ci $m = new TestMessage(); 482ffe3c632Sopenharmony_ci $m->setOptionalUint64(new TestMessage()); 483ffe3c632Sopenharmony_ci } 484ffe3c632Sopenharmony_ci 485ffe3c632Sopenharmony_ci /** 486ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 487ffe3c632Sopenharmony_ci */ 488ffe3c632Sopenharmony_ci public function testUint64FieldInvalidStringFail() 489ffe3c632Sopenharmony_ci { 490ffe3c632Sopenharmony_ci $m = new TestMessage(); 491ffe3c632Sopenharmony_ci $m->setOptionalUint64('abc'); 492ffe3c632Sopenharmony_ci } 493ffe3c632Sopenharmony_ci 494ffe3c632Sopenharmony_ci /** 495ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 496ffe3c632Sopenharmony_ci */ 497ffe3c632Sopenharmony_ci public function testFloatFieldInvalidTypeFail() 498ffe3c632Sopenharmony_ci { 499ffe3c632Sopenharmony_ci $m = new TestMessage(); 500ffe3c632Sopenharmony_ci $m->setOptionalFloat(new TestMessage()); 501ffe3c632Sopenharmony_ci } 502ffe3c632Sopenharmony_ci 503ffe3c632Sopenharmony_ci /** 504ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 505ffe3c632Sopenharmony_ci */ 506ffe3c632Sopenharmony_ci public function testFloatFieldInvalidStringFail() 507ffe3c632Sopenharmony_ci { 508ffe3c632Sopenharmony_ci $m = new TestMessage(); 509ffe3c632Sopenharmony_ci $m->setOptionalFloat('abc'); 510ffe3c632Sopenharmony_ci } 511ffe3c632Sopenharmony_ci 512ffe3c632Sopenharmony_ci /** 513ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 514ffe3c632Sopenharmony_ci */ 515ffe3c632Sopenharmony_ci public function testDoubleFieldInvalidTypeFail() 516ffe3c632Sopenharmony_ci { 517ffe3c632Sopenharmony_ci $m = new TestMessage(); 518ffe3c632Sopenharmony_ci $m->setOptionalDouble(new TestMessage()); 519ffe3c632Sopenharmony_ci } 520ffe3c632Sopenharmony_ci 521ffe3c632Sopenharmony_ci /** 522ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 523ffe3c632Sopenharmony_ci */ 524ffe3c632Sopenharmony_ci public function testDoubleFieldInvalidStringFail() 525ffe3c632Sopenharmony_ci { 526ffe3c632Sopenharmony_ci $m = new TestMessage(); 527ffe3c632Sopenharmony_ci $m->setOptionalDouble('abc'); 528ffe3c632Sopenharmony_ci } 529ffe3c632Sopenharmony_ci 530ffe3c632Sopenharmony_ci /** 531ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 532ffe3c632Sopenharmony_ci */ 533ffe3c632Sopenharmony_ci public function testBoolFieldInvalidStringFail() 534ffe3c632Sopenharmony_ci { 535ffe3c632Sopenharmony_ci $m = new TestMessage(); 536ffe3c632Sopenharmony_ci $m->setOptionalBool(new TestMessage()); 537ffe3c632Sopenharmony_ci } 538ffe3c632Sopenharmony_ci 539ffe3c632Sopenharmony_ci /** 540ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 541ffe3c632Sopenharmony_ci */ 542ffe3c632Sopenharmony_ci public function testStringFieldInvalidUTF8Fail() 543ffe3c632Sopenharmony_ci { 544ffe3c632Sopenharmony_ci $m = new TestMessage(); 545ffe3c632Sopenharmony_ci $hex = hex2bin("ff"); 546ffe3c632Sopenharmony_ci $m->setOptionalString($hex); 547ffe3c632Sopenharmony_ci } 548ffe3c632Sopenharmony_ci 549ffe3c632Sopenharmony_ci /** 550ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 551ffe3c632Sopenharmony_ci */ 552ffe3c632Sopenharmony_ci public function testMessageFieldWrongTypeFail() 553ffe3c632Sopenharmony_ci { 554ffe3c632Sopenharmony_ci $m = new TestMessage(); 555ffe3c632Sopenharmony_ci $a = 1; 556ffe3c632Sopenharmony_ci $m->setOptionalMessage($a); 557ffe3c632Sopenharmony_ci } 558ffe3c632Sopenharmony_ci 559ffe3c632Sopenharmony_ci /** 560ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 561ffe3c632Sopenharmony_ci */ 562ffe3c632Sopenharmony_ci public function testMessageFieldWrongClassFail() 563ffe3c632Sopenharmony_ci { 564ffe3c632Sopenharmony_ci $m = new TestMessage(); 565ffe3c632Sopenharmony_ci $m->setOptionalMessage(new TestMessage()); 566ffe3c632Sopenharmony_ci } 567ffe3c632Sopenharmony_ci 568ffe3c632Sopenharmony_ci /** 569ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 570ffe3c632Sopenharmony_ci */ 571ffe3c632Sopenharmony_ci public function testRepeatedFieldWrongTypeFail() 572ffe3c632Sopenharmony_ci { 573ffe3c632Sopenharmony_ci $m = new TestMessage(); 574ffe3c632Sopenharmony_ci $a = 1; 575ffe3c632Sopenharmony_ci $m->setRepeatedInt32($a); 576ffe3c632Sopenharmony_ci } 577ffe3c632Sopenharmony_ci 578ffe3c632Sopenharmony_ci /** 579ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 580ffe3c632Sopenharmony_ci */ 581ffe3c632Sopenharmony_ci public function testRepeatedFieldWrongObjectFail() 582ffe3c632Sopenharmony_ci { 583ffe3c632Sopenharmony_ci $m = new TestMessage(); 584ffe3c632Sopenharmony_ci $m->setRepeatedInt32($m); 585ffe3c632Sopenharmony_ci } 586ffe3c632Sopenharmony_ci 587ffe3c632Sopenharmony_ci /** 588ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 589ffe3c632Sopenharmony_ci */ 590ffe3c632Sopenharmony_ci public function testRepeatedFieldWrongRepeatedTypeFail() 591ffe3c632Sopenharmony_ci { 592ffe3c632Sopenharmony_ci $m = new TestMessage(); 593ffe3c632Sopenharmony_ci 594ffe3c632Sopenharmony_ci $repeated_int32 = new RepeatedField(GPBType::UINT32); 595ffe3c632Sopenharmony_ci $m->setRepeatedInt32($repeated_int32); 596ffe3c632Sopenharmony_ci } 597ffe3c632Sopenharmony_ci 598ffe3c632Sopenharmony_ci /** 599ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 600ffe3c632Sopenharmony_ci */ 601ffe3c632Sopenharmony_ci public function testRepeatedFieldWrongRepeatedMessageClassFail() 602ffe3c632Sopenharmony_ci { 603ffe3c632Sopenharmony_ci $m = new TestMessage(); 604ffe3c632Sopenharmony_ci 605ffe3c632Sopenharmony_ci $repeated_message = new RepeatedField(GPBType::MESSAGE, 606ffe3c632Sopenharmony_ci TestMessage::class); 607ffe3c632Sopenharmony_ci $m->setRepeatedMessage($repeated_message); 608ffe3c632Sopenharmony_ci } 609ffe3c632Sopenharmony_ci 610ffe3c632Sopenharmony_ci /** 611ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 612ffe3c632Sopenharmony_ci */ 613ffe3c632Sopenharmony_ci public function testMapFieldWrongTypeFail() 614ffe3c632Sopenharmony_ci { 615ffe3c632Sopenharmony_ci $m = new TestMessage(); 616ffe3c632Sopenharmony_ci $a = 1; 617ffe3c632Sopenharmony_ci $m->setMapInt32Int32($a); 618ffe3c632Sopenharmony_ci } 619ffe3c632Sopenharmony_ci 620ffe3c632Sopenharmony_ci /** 621ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 622ffe3c632Sopenharmony_ci */ 623ffe3c632Sopenharmony_ci public function testMapFieldWrongObjectFail() 624ffe3c632Sopenharmony_ci { 625ffe3c632Sopenharmony_ci $m = new TestMessage(); 626ffe3c632Sopenharmony_ci $m->setMapInt32Int32($m); 627ffe3c632Sopenharmony_ci } 628ffe3c632Sopenharmony_ci 629ffe3c632Sopenharmony_ci /** 630ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 631ffe3c632Sopenharmony_ci */ 632ffe3c632Sopenharmony_ci public function testMapFieldWrongRepeatedTypeFail() 633ffe3c632Sopenharmony_ci { 634ffe3c632Sopenharmony_ci $m = new TestMessage(); 635ffe3c632Sopenharmony_ci 636ffe3c632Sopenharmony_ci $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); 637ffe3c632Sopenharmony_ci $m->setMapInt32Int32($map_uint32_uint32); 638ffe3c632Sopenharmony_ci } 639ffe3c632Sopenharmony_ci 640ffe3c632Sopenharmony_ci /** 641ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 642ffe3c632Sopenharmony_ci */ 643ffe3c632Sopenharmony_ci public function testMapFieldWrongRepeatedMessageClassFail() 644ffe3c632Sopenharmony_ci { 645ffe3c632Sopenharmony_ci $m = new TestMessage(); 646ffe3c632Sopenharmony_ci 647ffe3c632Sopenharmony_ci $map_int32_message = new MapField(GPBType::INT32, 648ffe3c632Sopenharmony_ci GPBType::MESSAGE, 649ffe3c632Sopenharmony_ci TestMessage::class); 650ffe3c632Sopenharmony_ci $m->setMapInt32Message($map_int32_message); 651ffe3c632Sopenharmony_ci } 652ffe3c632Sopenharmony_ci 653ffe3c632Sopenharmony_ci /** 654ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 655ffe3c632Sopenharmony_ci */ 656ffe3c632Sopenharmony_ci public function testMessageMergeFromInvalidTypeFail() 657ffe3c632Sopenharmony_ci { 658ffe3c632Sopenharmony_ci $m = new TestMessage(); 659ffe3c632Sopenharmony_ci $n = new Sub(); 660ffe3c632Sopenharmony_ci $m->mergeFrom($n); 661ffe3c632Sopenharmony_ci } 662ffe3c632Sopenharmony_ci 663ffe3c632Sopenharmony_ci /** 664ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 665ffe3c632Sopenharmony_ci */ 666ffe3c632Sopenharmony_ci public function testInt32SetStringKeyFail() 667ffe3c632Sopenharmony_ci { 668ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT32, GPBType::INT32); 669ffe3c632Sopenharmony_ci $arr['abc'] = 0; 670ffe3c632Sopenharmony_ci } 671ffe3c632Sopenharmony_ci 672ffe3c632Sopenharmony_ci /** 673ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 674ffe3c632Sopenharmony_ci */ 675ffe3c632Sopenharmony_ci public function testInt32SetStringValueFail() 676ffe3c632Sopenharmony_ci { 677ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT32, GPBType::INT32); 678ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 679ffe3c632Sopenharmony_ci } 680ffe3c632Sopenharmony_ci 681ffe3c632Sopenharmony_ci /** 682ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 683ffe3c632Sopenharmony_ci */ 684ffe3c632Sopenharmony_ci public function testInt32SetMessageKeyFail() 685ffe3c632Sopenharmony_ci { 686ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT32, GPBType::INT32); 687ffe3c632Sopenharmony_ci $arr[new Sub()] = 0; 688ffe3c632Sopenharmony_ci } 689ffe3c632Sopenharmony_ci 690ffe3c632Sopenharmony_ci /** 691ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 692ffe3c632Sopenharmony_ci */ 693ffe3c632Sopenharmony_ci public function testInt32SetMessageValueFail() 694ffe3c632Sopenharmony_ci { 695ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT32, GPBType::INT32); 696ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 697ffe3c632Sopenharmony_ci } 698ffe3c632Sopenharmony_ci 699ffe3c632Sopenharmony_ci /** 700ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 701ffe3c632Sopenharmony_ci */ 702ffe3c632Sopenharmony_ci public function testUint32SetStringKeyFail() 703ffe3c632Sopenharmony_ci { 704ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT32, GPBType::UINT32); 705ffe3c632Sopenharmony_ci $arr['abc'] = 0; 706ffe3c632Sopenharmony_ci } 707ffe3c632Sopenharmony_ci 708ffe3c632Sopenharmony_ci /** 709ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 710ffe3c632Sopenharmony_ci */ 711ffe3c632Sopenharmony_ci public function testUint32SetStringValueFail() 712ffe3c632Sopenharmony_ci { 713ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT32, GPBType::UINT32); 714ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 715ffe3c632Sopenharmony_ci } 716ffe3c632Sopenharmony_ci 717ffe3c632Sopenharmony_ci /** 718ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 719ffe3c632Sopenharmony_ci */ 720ffe3c632Sopenharmony_ci public function testUint32SetMessageKeyFail() 721ffe3c632Sopenharmony_ci { 722ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT32, GPBType::UINT32); 723ffe3c632Sopenharmony_ci $arr[new Sub()] = 0; 724ffe3c632Sopenharmony_ci } 725ffe3c632Sopenharmony_ci 726ffe3c632Sopenharmony_ci /** 727ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 728ffe3c632Sopenharmony_ci */ 729ffe3c632Sopenharmony_ci public function testUint32SetMessageValueFail() 730ffe3c632Sopenharmony_ci { 731ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT32, GPBType::UINT32); 732ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 733ffe3c632Sopenharmony_ci } 734ffe3c632Sopenharmony_ci 735ffe3c632Sopenharmony_ci /** 736ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 737ffe3c632Sopenharmony_ci */ 738ffe3c632Sopenharmony_ci public function testInt64SetStringKeyFail() 739ffe3c632Sopenharmony_ci { 740ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::INT64); 741ffe3c632Sopenharmony_ci $arr['abc'] = 0; 742ffe3c632Sopenharmony_ci } 743ffe3c632Sopenharmony_ci 744ffe3c632Sopenharmony_ci /** 745ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 746ffe3c632Sopenharmony_ci */ 747ffe3c632Sopenharmony_ci public function testInt64SetStringValueFail() 748ffe3c632Sopenharmony_ci { 749ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::INT64); 750ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 751ffe3c632Sopenharmony_ci } 752ffe3c632Sopenharmony_ci 753ffe3c632Sopenharmony_ci /** 754ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 755ffe3c632Sopenharmony_ci */ 756ffe3c632Sopenharmony_ci public function testInt64SetMessageKeyFail() 757ffe3c632Sopenharmony_ci { 758ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::INT64); 759ffe3c632Sopenharmony_ci $arr[new Sub()] = 0; 760ffe3c632Sopenharmony_ci } 761ffe3c632Sopenharmony_ci 762ffe3c632Sopenharmony_ci /** 763ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 764ffe3c632Sopenharmony_ci */ 765ffe3c632Sopenharmony_ci public function testInt64SetMessageValueFail() 766ffe3c632Sopenharmony_ci { 767ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::INT64); 768ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 769ffe3c632Sopenharmony_ci } 770ffe3c632Sopenharmony_ci 771ffe3c632Sopenharmony_ci /** 772ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 773ffe3c632Sopenharmony_ci */ 774ffe3c632Sopenharmony_ci public function testUint64SetStringKeyFail() 775ffe3c632Sopenharmony_ci { 776ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT64, GPBType::UINT64); 777ffe3c632Sopenharmony_ci $arr['abc'] = 0; 778ffe3c632Sopenharmony_ci } 779ffe3c632Sopenharmony_ci 780ffe3c632Sopenharmony_ci /** 781ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 782ffe3c632Sopenharmony_ci */ 783ffe3c632Sopenharmony_ci public function testUint64SetStringValueFail() 784ffe3c632Sopenharmony_ci { 785ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT64, GPBType::UINT64); 786ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 787ffe3c632Sopenharmony_ci } 788ffe3c632Sopenharmony_ci 789ffe3c632Sopenharmony_ci /** 790ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 791ffe3c632Sopenharmony_ci */ 792ffe3c632Sopenharmony_ci public function testUint64SetMessageKeyFail() 793ffe3c632Sopenharmony_ci { 794ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT64, GPBType::UINT64); 795ffe3c632Sopenharmony_ci $arr[new Sub()] = 0; 796ffe3c632Sopenharmony_ci } 797ffe3c632Sopenharmony_ci 798ffe3c632Sopenharmony_ci /** 799ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 800ffe3c632Sopenharmony_ci */ 801ffe3c632Sopenharmony_ci public function testUint64SetMessageValueFail() 802ffe3c632Sopenharmony_ci { 803ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::UINT64, GPBType::UINT64); 804ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 805ffe3c632Sopenharmony_ci } 806ffe3c632Sopenharmony_ci 807ffe3c632Sopenharmony_ci /** 808ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 809ffe3c632Sopenharmony_ci */ 810ffe3c632Sopenharmony_ci public function testDoubleSetStringValueFail() 811ffe3c632Sopenharmony_ci { 812ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); 813ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 814ffe3c632Sopenharmony_ci } 815ffe3c632Sopenharmony_ci 816ffe3c632Sopenharmony_ci /** 817ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 818ffe3c632Sopenharmony_ci */ 819ffe3c632Sopenharmony_ci public function testDoubleSetMessageValueFail() 820ffe3c632Sopenharmony_ci { 821ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); 822ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 823ffe3c632Sopenharmony_ci } 824ffe3c632Sopenharmony_ci 825ffe3c632Sopenharmony_ci /** 826ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 827ffe3c632Sopenharmony_ci */ 828ffe3c632Sopenharmony_ci public function testBoolSetMessageKeyFail() 829ffe3c632Sopenharmony_ci { 830ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::BOOL, GPBType::BOOL); 831ffe3c632Sopenharmony_ci $arr[new Sub()] = true; 832ffe3c632Sopenharmony_ci } 833ffe3c632Sopenharmony_ci 834ffe3c632Sopenharmony_ci /** 835ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 836ffe3c632Sopenharmony_ci */ 837ffe3c632Sopenharmony_ci public function testBoolSetMessageValueFail() 838ffe3c632Sopenharmony_ci { 839ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::BOOL, GPBType::BOOL); 840ffe3c632Sopenharmony_ci $arr[true] = new Sub(); 841ffe3c632Sopenharmony_ci } 842ffe3c632Sopenharmony_ci 843ffe3c632Sopenharmony_ci /** 844ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 845ffe3c632Sopenharmony_ci */ 846ffe3c632Sopenharmony_ci public function testStringSetInvalidUTF8KeyFail() 847ffe3c632Sopenharmony_ci { 848ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::STRING, GPBType::STRING); 849ffe3c632Sopenharmony_ci $arr[hex2bin("ff")] = 'abc'; 850ffe3c632Sopenharmony_ci } 851ffe3c632Sopenharmony_ci 852ffe3c632Sopenharmony_ci /** 853ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 854ffe3c632Sopenharmony_ci */ 855ffe3c632Sopenharmony_ci public function testStringSetInvalidUTF8ValueFail() 856ffe3c632Sopenharmony_ci { 857ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::STRING, GPBType::STRING); 858ffe3c632Sopenharmony_ci $arr['abc'] = hex2bin("ff"); 859ffe3c632Sopenharmony_ci } 860ffe3c632Sopenharmony_ci 861ffe3c632Sopenharmony_ci /** 862ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 863ffe3c632Sopenharmony_ci */ 864ffe3c632Sopenharmony_ci public function testStringSetMessageKeyFail() 865ffe3c632Sopenharmony_ci { 866ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::STRING, GPBType::STRING); 867ffe3c632Sopenharmony_ci $arr[new Sub()] = 'abc'; 868ffe3c632Sopenharmony_ci } 869ffe3c632Sopenharmony_ci 870ffe3c632Sopenharmony_ci /** 871ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 872ffe3c632Sopenharmony_ci */ 873ffe3c632Sopenharmony_ci public function testStringSetMessageValueFail() 874ffe3c632Sopenharmony_ci { 875ffe3c632Sopenharmony_ci $arr = new MapField(GPBType::STRING, GPBType::STRING); 876ffe3c632Sopenharmony_ci $arr['abc'] = new Sub(); 877ffe3c632Sopenharmony_ci } 878ffe3c632Sopenharmony_ci 879ffe3c632Sopenharmony_ci /** 880ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 881ffe3c632Sopenharmony_ci */ 882ffe3c632Sopenharmony_ci public function testMessageSetIntValueFail() 883ffe3c632Sopenharmony_ci { 884ffe3c632Sopenharmony_ci $arr = 885ffe3c632Sopenharmony_ci new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); 886ffe3c632Sopenharmony_ci $arr[0] = 0; 887ffe3c632Sopenharmony_ci } 888ffe3c632Sopenharmony_ci 889ffe3c632Sopenharmony_ci /** 890ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 891ffe3c632Sopenharmony_ci */ 892ffe3c632Sopenharmony_ci public function testMessageSetStringValueFail() 893ffe3c632Sopenharmony_ci { 894ffe3c632Sopenharmony_ci $arr = 895ffe3c632Sopenharmony_ci new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); 896ffe3c632Sopenharmony_ci $arr[0] = 'abc'; 897ffe3c632Sopenharmony_ci } 898ffe3c632Sopenharmony_ci 899ffe3c632Sopenharmony_ci /** 900ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 901ffe3c632Sopenharmony_ci */ 902ffe3c632Sopenharmony_ci public function testMessageSetOtherMessageValueFail() 903ffe3c632Sopenharmony_ci { 904ffe3c632Sopenharmony_ci $arr = 905ffe3c632Sopenharmony_ci new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); 906ffe3c632Sopenharmony_ci $arr[0] = new Sub(); 907ffe3c632Sopenharmony_ci } 908ffe3c632Sopenharmony_ci 909ffe3c632Sopenharmony_ci /** 910ffe3c632Sopenharmony_ci * @expectedException PHPUnit_Framework_Error 911ffe3c632Sopenharmony_ci */ 912ffe3c632Sopenharmony_ci public function testMessageSetNullFailMap() 913ffe3c632Sopenharmony_ci { 914ffe3c632Sopenharmony_ci $arr = 915ffe3c632Sopenharmony_ci new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); 916ffe3c632Sopenharmony_ci $null = NULL; 917ffe3c632Sopenharmony_ci $arr[0] = $null; 918ffe3c632Sopenharmony_ci } 919ffe3c632Sopenharmony_ci 920ffe3c632Sopenharmony_ci} 921