summaryrefslogtreecommitdiff
path: root/tests/output/ob_start_basic_006.phpt
blob: 3e5666fd6b078f0e8ae54e94b4aab1820f91335d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--TEST--
ob_start(): ensure multiple buffer initialization with a single call using arrays is not supported on PHP6 (http://bugs.php.net/42641)
--FILE--
<?php
/*
 * Function is implemented in main/output.c
*/

function f($string) {
    static $i=0;
    $i++;
    $len = strlen($string);
    return "f[call:$i; len:$len] - $string\n";
}

Class C {
    public $id = 'none';

    function __construct($id) {
        $this->id = $id;
    }

    static function g($string) {
        static $i=0;
        $i++;
        $len = strlen($string);
        return "C::g[call:$i; len:$len] - $string\n";
    }

    function h($string) {
        static $i=0;
        $i++;
        $len = strlen($string);
        return "C::h[call:$i; len:$len; id:$this->id] - $string\n";
    }
}

function checkAndClean() {
  print_r(ob_list_handlers());
  while (ob_get_level()>0) {
    ob_end_flush();
  }
}

echo "\n ---> Test arrays:\n";
var_dump(ob_start(array("f")));
checkAndClean();

var_dump(ob_start(array("f", "f")));
checkAndClean();

var_dump(ob_start(array("f", "C::g", "f", "C::g")));
checkAndClean();

var_dump(ob_start(array("f", "non_existent", "f")));
checkAndClean();

var_dump(ob_start(array("f", "non_existent", "f", "f")));
checkAndClean();

$c = new c('originalID');
var_dump(ob_start(array($c, "h")));
checkAndClean();

var_dump(ob_start(array($c, "h")));
$c->id = 'changedID';
checkAndClean();

$c->id = 'changedIDagain';
var_dump(ob_start(array('f', 'C::g', array(array($c, "g"), array($c, "h")))));
checkAndClean();
?>
--EXPECTF--
---> Test arrays:

Warning: ob_start(): array must have exactly two members in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)

Warning: ob_start(): class 'f' not found in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)

Warning: ob_start(): array must have exactly two members in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)

Warning: ob_start(): array must have exactly two members in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)

Warning: ob_start(): array must have exactly two members in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)
C::h[call:1; len:37; id:originalID] - bool(true)
Array
(
    [0] => C::h
)

C::h[call:2; len:37; id:changedID] - bool(true)
Array
(
    [0] => C::h
)


Warning: ob_start(): array must have exactly two members in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d
bool(false)
Array
(
)