]> granicus.if.org Git - php/commitdiff
Add test-case from bug #55157
authorEric Poe <eric.poe@gmail.com>
Sat, 4 Feb 2017 02:56:18 +0000 (21:56 -0500)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 2 Mar 2017 11:22:48 +0000 (12:22 +0100)
The issue itself is not fixed, this is just a workaround.

ext/spl/tests/bug55157_variation.phpt [new file with mode: 0644]

diff --git a/ext/spl/tests/bug55157_variation.phpt b/ext/spl/tests/bug55157_variation.phpt
new file mode 100644 (file)
index 0000000..762caa8
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #55157: ArrayIterator always skips the second element in the array when calling offsetUnset()
+--DESCRIPTION--
+One of the test cases from bug #55157. This is a workaround around the problem that has worked
+since PHP 5.0.4.
+--FILE--
+<?php
+$nums = range(0, 3);
+$numIt = new ArrayIterator($nums);
+
+for ($numIt->rewind(); $numIt->valid();) {
+    echo "{$numIt->key()} => {$numIt->current()}\n";
+    $numIt->offsetUnset($numIt->key());
+}
+?>
+--EXPECT--
+0 => 0
+1 => 1
+2 => 2
+3 => 3