~ubuntu-branches/ubuntu/raring/php5/raring

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-18 16:10:26 UTC
  • mfrom: (1.1.24) (0.3.58 sid)
  • Revision ID: package-import@ubuntu.com-20120618161026-hg1fc5r9z1a4hlqz
Tags: 5.4.4-1ubuntu1
* Merge from Debian unstable. Remaining changes:
  - d/rules: Simplify apache config settings since we never build 
    interbase or firebird.
  - debian/rules: export DEB_HOST_MULTIARCH properly.
  - Add build-dependency on lemon, which we now need.
  - Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
  - Dropped libcurl-dev not in the archive.
  - debian/control: replace build-depends on mysql-server with
    mysql-server-core-5.5 and mysql-client-5.5 to avoid upstart and
    mysql-server-5.5 postinst confusion with starting up multiple
    mysqlds listening on the same port.
  - Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions
    already in universe.
  - Dropped libonig-dev and libqgdbm since its in universe. (libonig MIR
    has been declined due to an inactive upstream. So this is probably
    a permanent change).
  - modulelist: Drop imap, interbase, sybase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
    * stop mysql instance on clean just in case we failed in tests
* Dropped Changes:
  * d/rules: enable Suhosin patch with PHP5_SUHOSIN=yes -- Upstream suhosin
    has been slow to adopt PHP 5.4, and is showing signs of disengagement.
    Therefore, we will follow Debian's lead and drop Suhosin for now.
  - d/control: build-depend on mysql 5.5 instead of 5.1 for running tests.
    -- Debian just deps on mysql-server
  - Suggest php5-suhosin rather than recommends. -- Dropping suhosin
  - d/setup-mysql.sh: modify to work with mysql 5.5 differences -- superseded
    in Debian.
  - Only build php5-sqlite for sqlite3, dropping the obsolete sqlite2. --
    superseded in Debian
  - d/maxlifetime: Improve maxlifetime script to scan for more SAPIs and 
    scan all *.ini in conf.d directory. -- Change came from Debian
  - d/libapache2-mod-php5.postinst,libapache2-mod-php5filter.postinst: 
    Restart apache on first install to ensure module is fully enabled.
    -- Change came from Debian
  - debian/patches/php5-CVE-2012-1823.patch: filter query strings that
    are prefixed with '-' -- Fixed upstream
  - debian/control: Recommend php5-dev for php-pear. -- This was a poorly
    conceived idea anyway.
  - Pre-Depend on a new enough version of dpkg for dpkg-maintscript-helper
    rather than checking whether it exists at run-time, leading to more
    predictable behaviour on upgrades. -- Applied in Debian
  - d/p/gd-multiarch-fix.patch: superseded
* d/NEWS: add note explaining that SUHOSIN is no longer enabled in the
  Ubuntu packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
CallbackFilterIterator
 
3
--FILE--
 
4
<?php
 
5
 
 
6
class A {
 
7
    function test($value, $key, $inner) {
 
8
        return test($value, $key, $inner);
 
9
    }
 
10
}
 
11
 
 
12
class B {
 
13
    static function test($value, $key, $inner) {
 
14
        return test($value, $key, $inner);
 
15
    }
 
16
}
 
17
 
 
18
function test($value, $key, $inner) {
 
19
        printf("%s / %s / %d / %d\n"
 
20
                , $value
 
21
                , $key
 
22
                , $value == $inner->current()
 
23
                , $key == $inner->key()
 
24
        );
 
25
        return $value === 1 || $value === 4;
 
26
}
 
27
 
 
28
$tests = array(
 
29
    'instance method'    => function() { return array(new A, 'test'); },
 
30
    'static method'      => function() { return array('B', 'test'); },
 
31
    'static method (2)'  => function() { return 'B::test'; },
 
32
    'function'           => function() { return 'test'; },
 
33
    'anonymous function' => function() { return function($value, $key, $inner) { return test($value, $key, $inner); }; },
 
34
);
 
35
 
 
36
foreach($tests as $name => $test) {
 
37
 
 
38
    $callback = $test();
 
39
    $it = new ArrayIterator(range(1, 5));
 
40
    $it = new CallbackFilterIterator($it, $callback);
 
41
 
 
42
    echo " = $name =\n";
 
43
 
 
44
    foreach($it as $value) {
 
45
        echo "=> $value\n";
 
46
    }
 
47
 
 
48
        // same test, with no reference to callback
 
49
 
 
50
    $it = new ArrayIterator(range(1, 5));
 
51
    $it = new CallbackFilterIterator($it, $test());
 
52
    unset($callback);
 
53
 
 
54
    foreach($it as $value) {
 
55
        echo "=> $value\n";
 
56
    }
 
57
}
 
58
--EXPECT--
 
59
= instance method =
 
60
1 / 0 / 1 / 1
 
61
=> 1
 
62
2 / 1 / 1 / 1
 
63
3 / 2 / 1 / 1
 
64
4 / 3 / 1 / 1
 
65
=> 4
 
66
5 / 4 / 1 / 1
 
67
1 / 0 / 1 / 1
 
68
=> 1
 
69
2 / 1 / 1 / 1
 
70
3 / 2 / 1 / 1
 
71
4 / 3 / 1 / 1
 
72
=> 4
 
73
5 / 4 / 1 / 1
 
74
 = static method =
 
75
1 / 0 / 1 / 1
 
76
=> 1
 
77
2 / 1 / 1 / 1
 
78
3 / 2 / 1 / 1
 
79
4 / 3 / 1 / 1
 
80
=> 4
 
81
5 / 4 / 1 / 1
 
82
1 / 0 / 1 / 1
 
83
=> 1
 
84
2 / 1 / 1 / 1
 
85
3 / 2 / 1 / 1
 
86
4 / 3 / 1 / 1
 
87
=> 4
 
88
5 / 4 / 1 / 1
 
89
 = static method (2) =
 
90
1 / 0 / 1 / 1
 
91
=> 1
 
92
2 / 1 / 1 / 1
 
93
3 / 2 / 1 / 1
 
94
4 / 3 / 1 / 1
 
95
=> 4
 
96
5 / 4 / 1 / 1
 
97
1 / 0 / 1 / 1
 
98
=> 1
 
99
2 / 1 / 1 / 1
 
100
3 / 2 / 1 / 1
 
101
4 / 3 / 1 / 1
 
102
=> 4
 
103
5 / 4 / 1 / 1
 
104
 = function =
 
105
1 / 0 / 1 / 1
 
106
=> 1
 
107
2 / 1 / 1 / 1
 
108
3 / 2 / 1 / 1
 
109
4 / 3 / 1 / 1
 
110
=> 4
 
111
5 / 4 / 1 / 1
 
112
1 / 0 / 1 / 1
 
113
=> 1
 
114
2 / 1 / 1 / 1
 
115
3 / 2 / 1 / 1
 
116
4 / 3 / 1 / 1
 
117
=> 4
 
118
5 / 4 / 1 / 1
 
119
 = anonymous function =
 
120
1 / 0 / 1 / 1
 
121
=> 1
 
122
2 / 1 / 1 / 1
 
123
3 / 2 / 1 / 1
 
124
4 / 3 / 1 / 1
 
125
=> 4
 
126
5 / 4 / 1 / 1
 
127
1 / 0 / 1 / 1
 
128
=> 1
 
129
2 / 1 / 1 / 1
 
130
3 / 2 / 1 / 1
 
131
4 / 3 / 1 / 1
 
132
=> 4
 
133
5 / 4 / 1 / 1