diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-04-19 16:23:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 16:23:51 -0700 |
commit | 190b5270c8717ca343db42da489e5e7d6d9efb2c (patch) | |
tree | 3815f20268bc56aac88267004149f9e4eb634223 /php/tests/array_test.php | |
parent | 43234828da6ae3a3a3ada25d11488fdfd080b79c (diff) | |
download | protobuf-190b5270c8717ca343db42da489e5e7d6d9efb2c.tar.gz protobuf-190b5270c8717ca343db42da489e5e7d6d9efb2c.tar.bz2 protobuf-190b5270c8717ca343db42da489e5e7d6d9efb2c.zip |
Make PHP c extension work with PHP7 (#2951)
Diffstat (limited to 'php/tests/array_test.php')
-rw-r--r-- | php/tests/array_test.php | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/php/tests/array_test.php b/php/tests/array_test.php index a4cad719..b55408da 100644 --- a/php/tests/array_test.php +++ b/php/tests/array_test.php @@ -751,23 +751,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr []= $sub_m; $this->assertSame(1, $arr[0]->getA()); - $null = null; - $arr []= $null; - $this->assertNull($arr[1]); - - $this->assertEquals(2, count($arr)); - - for ($i = 0; $i < count($arr); $i++) { - $arr[$i] = $null; - $this->assertNull($arr[$i]); - } + $this->assertEquals(1, count($arr)); // Test set. + $sub_m = new TestMessage_Sub(); + $sub_m->setA(2); $arr [0]= $sub_m; - $this->assertSame(1, $arr[0]->getA()); - - $arr [1]= $null; - $this->assertNull($arr[1]); + $this->assertSame(2, $arr[0]->getA()); } /** @@ -817,6 +807,27 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr []= new TestMessage; } + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageAppendNullFail() + { + $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); + $null = null; + $arr []= $null; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetNullFail() + { + $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); + $arr []= new TestMessage_Sub(); + $null = null; + $arr[0] = $null; + } + ######################################################### # Test offset type ######################################################### |