aboutsummaryrefslogtreecommitdiff
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.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/php/tests/array_test.php b/php/tests/array_test.php
index a118b54c..a79a08bc 100644
--- a/php/tests/array_test.php
+++ b/php/tests/array_test.php
@@ -65,6 +65,17 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
$this->assertSame(3, $arr[6]);
$arr [7]= MAX_INT32_STRING;
$this->assertSame(MAX_INT32, $arr[7]);
+
+ // Test foreach.
+ $arr = new RepeatedField(GPBType::INT32);
+ for ($i = 0; $i < 3; $i++) {
+ $arr []= $i;
+ }
+ $i = 0;
+ foreach ($arr as $val) {
+ $this->assertSame($i++, $val);
+ }
+ $this->assertSame(3, $i);
}
/**