aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/tests/array_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/tests/array_test.php')
-rw-r--r--php/tests/array_test.php39
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
#########################################################