~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/spl/tests/array_007.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
SPL: ArrayObject/Iterator from IteratorAggregate
 
3
--SKIPIF--
 
4
<?php if (!extension_loaded("spl")) print "skip"; ?>
 
5
--FILE--
 
6
<?php
 
7
 
 
8
// This test also needs to exclude the protected and private variables 
 
9
// since they cannot be accessed from the external object which iterates 
 
10
// them.
 
11
 
 
12
class test implements IteratorAggregate
 
13
{
 
14
        public    $pub = "public";
 
15
        protected $pro = "protected";
 
16
        private   $pri = "private";
 
17
        
 
18
        function __construct()
 
19
        {
 
20
                $this->imp = "implicit";
 
21
        }
 
22
        
 
23
        function getIterator()
 
24
        {
 
25
                $it = new ArrayObject($this);
 
26
                return $it->getIterator();
 
27
        }
 
28
};
 
29
 
 
30
$test = new test;
 
31
$test->dyn = "dynamic";
 
32
 
 
33
print_r($test);
 
34
 
 
35
print_r($test->getIterator());
 
36
 
 
37
foreach($test as $key => $val)
 
38
{
 
39
        echo "$key => $val\n";
 
40
}
 
41
 
 
42
?>
 
43
===DONE===
 
44
<?php exit(0); ?>
 
45
--EXPECTF--
 
46
test Object
 
47
(
 
48
    [pub] => public
 
49
    [pro:protected] => protected
 
50
    [pri:private] => private
 
51
    [imp] => implicit
 
52
    [dyn] => dynamic
 
53
)
 
54
ArrayIterator Object
 
55
(
 
56
    [pub] => public
 
57
    [pro:protected] => protected
 
58
    [pri:private] => private
 
59
    [imp] => implicit
 
60
    [dyn] => dynamic
 
61
)
 
62
pub => public
 
63
imp => implicit
 
64
dyn => dynamic
 
65
===DONE===