aboutsummaryrefslogtreecommitdiff
path: root/php/tests/array_test.php
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2016-11-08 11:38:34 -0800
committerGitHub <noreply@github.com>2016-11-08 11:38:34 -0800
commit1f2dbc899b634f3236e1923a90683eebed283d52 (patch)
treeff3da4a7614582c48ee6b2964931803ccb30fe89 /php/tests/array_test.php
parent0d7199edc802299bdba39400c04f119c7db82667 (diff)
downloadprotobuf-1f2dbc899b634f3236e1923a90683eebed283d52.tar.gz
protobuf-1f2dbc899b634f3236e1923a90683eebed283d52.tar.bz2
protobuf-1f2dbc899b634f3236e1923a90683eebed283d52.zip
Implement RepeatedFieldIter for c extension. (#2333)
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);
}
/**