xref: /PHP-8.3/ext/spl/tests/iterator_013.phpt (revision f8d79582)
1--TEST--
2SPL: AppendIterator
3--FILE--
4<?php
5
6echo "===Empty===\n";
7
8$it = new AppendIterator;
9
10foreach($it as $key=>$val)
11{
12    echo "$key=>$val\n";
13}
14
15echo "===Append===\n";
16
17$it->append(new ArrayIterator(array(0 => 'A', 1 => 'B')));
18
19foreach($it as $key=>$val)
20{
21    echo "$key=>$val\n";
22}
23
24echo "===Rewind===\n";
25
26foreach($it as $key=>$val)
27{
28    echo "$key=>$val\n";
29}
30
31echo "===Append===\n";
32
33$it->append(new ArrayIterator(array(2 => 'C', 3 => 'D')));
34
35foreach(new NoRewindIterator($it) as $key=>$val)
36{
37    echo "$key=>$val\n";
38}
39
40echo "===Rewind===\n";
41
42foreach($it as $key=>$val)
43{
44    echo "$key=>$val\n";
45}
46
47?>
48--EXPECT--
49===Empty===
50===Append===
510=>A
521=>B
53===Rewind===
540=>A
551=>B
56===Append===
572=>C
583=>D
59===Rewind===
600=>A
611=>B
622=>C
633=>D
64