From 1f2dbc899b634f3236e1923a90683eebed283d52 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 8 Nov 2016 11:38:34 -0800 Subject: Implement RepeatedFieldIter for c extension. (#2333) --- php/tests/array_test.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'php/tests') 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); } /** -- cgit v1.2.3