Discussion:
svn: /pear/pear-core/trunk/tests/PEAR/ bugPHP14744.phpt pear1.phpt
Helgi Þormar Þorbjörnsson
2011-07-09 23:35:44 UTC
Permalink
dufuz Sat, 09 Jul 2011 23:35:44 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=313097

Log:
Split the bug test out of the main test to keep some separation and granularity

Changed paths:
A pear/pear-core/trunk/tests/PEAR/bugPHP14744.phpt
U pear/pear-core/trunk/tests/PEAR/pear1.phpt

Added: pear/pear-core/trunk/tests/PEAR/bugPHP14744.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR/bugPHP14744.phpt (rev 0)
+++ pear/pear-core/trunk/tests/PEAR/bugPHP14744.phpt 2011-07-09 23:35:44 UTC (rev 313097)
@@ -0,0 +1,49 @@
+--TEST--
+PHP Bug #14744: destructor emulation problem
+--SKIPIF--
+<?php
+if (!getenv('PHP_PEAR_RUNTESTS')) {
+ echo 'skip';
+}
+?>
+--FILE--
+<?php
+
+require_once "PEAR.php";
+
+// 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";
+ }
+}
+
+echo "testing 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 bug #14744
+#bug 14744# Other class constructor: other->a == 'default value'
+#bug 14744# Other class modified: other->a == 'new value'
+..
+script exiting...
+..
+#bug 14744# Other class destructor: other->a == 'new value'
\ No newline at end of file

Modified: pear/pear-core/trunk/tests/PEAR/pear1.phpt
===================================================================
--- pear/pear-core/trunk/tests/PEAR/pear1.phpt 2011-07-09 23:35:34 UTC (rev 313096)
+++ pear/pear-core/trunk/tests/PEAR/pear1.phpt 2011-07-09 23:35:44 UTC (rev 313097)
@@ -33,23 +33,8 @@
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");
@@ -57,13 +42,8 @@
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";
@@ -75,10 +55,6 @@
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...
..
@@ -87,4 +63,3 @@
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'

Loading...