summaryrefslogtreecommitdiff
path: root/pear/tests/pear1.phpt
blob: f65d6a4f1930dcc8c5b9348ae2ff74c230e7c959 (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
--TEST--
PEAR constructor/destructor test
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
    echo 'skip';
}
?>
--FILE--
<?php

require_once "PEAR.php";

class TestPEAR extends PEAR {
    function TestPEAR($name) {
        $this->_debug = true;
        $this->name = $name;
        $this->PEAR();
    }
    function _TestPEAR() {
        print "This is the TestPEAR($this->name) destructor\n";
        $this->_PEAR();
    }
}

class Test2 extends PEAR {
    function _Test2() {
        print "This is the Test2 destructor\n";
        $this->_PEAR();
    }
}

class Test3 extends Test2 {
}

// test for bug http://bugs.php.net/bug.php?id=14744
class Other extends Pear {

    var $a = 'default value';

    function Other() {
        $this->PEAR();
    }

    function _Other() {
        // $a was modified but here misteriously returns to be
        // the original value. That makes the destructor useless
        // The correct value for $a in the destructor shoud be "new value"
        echo "#bug 14744# Other class destructor: other->a == '" . $this->a ."'\n";
    }
}

print "testing plain destructors\n";
$o = new TestPEAR("test1");
$p = new TestPEAR("test2");
print "..\n";
print "testing inherited destructors\n";
$q = new Test3;

echo "...\ntesting bug #14744\n";
$other =& new Other;
echo "#bug 14744# Other class constructor: other->a == '" . $other->a ."'\n";
// Modify $a
$other->a = 'new value';
echo "#bug 14744# Other class modified: other->a == '" . $other->a ."'\n";

print "..\n";
print "script exiting...\n";
print "..\n";

?>
--EXPECT--
testing plain destructors
PEAR constructor called, class=testpear
PEAR constructor called, class=testpear
..
testing inherited destructors
...
testing bug #14744
#bug 14744# Other class constructor: other->a == 'default value'
#bug 14744# Other class modified: other->a == 'new value'
..
script exiting...
..
This is the TestPEAR(test1) destructor
PEAR destructor called, class=testpear
This is the TestPEAR(test2) destructor
PEAR destructor called, class=testpear
This is the Test2 destructor
#bug 14744# Other class destructor: other->a == 'new value'