Menu

#15 class Exception is a predefined one in php 5.0.2

open
nobody
None
5
2014-10-07
2004-09-15
No

Hello, I was trying to use your phpUnit with php 5.0.2
and met a name
resolution conflict. Exception class is predefined in
php 5.0.0, as you know. So, I've managed to fix the
problem.
Here's the patch that works fine in my case --
runtests2.php runs completely as it should.

Index: phpunit.php

RCS file: /cvsroot/phpunit/phpunit/phpunit.php,v
retrieving revision 1.20
diff -u -r1.20 phpunit.php
--- phpunit.php 31 Jul 2004 07:35:03 -0000 1.20
+++ phpunit.php 14 Sep 2004 09:36:38 -0000
@@ -53,11 +53,11 @@
}
}

-class Exception {
+class phpUnitException {
/* Emulate a Java exception, sort of... */
var $message;
var $type;
- function Exception($message, $type = 'FAILURE') {
+ function phpUnitException($message, $type = 'FAILURE') {
$this->message = $message;
$this->type = $type;
}
@@ -260,13 +260,13 @@
//printf("TestCase::fail(%s)<br>\n", ($message) ?
$message : '');
/* JUnit throws AssertionFailedError here. We
just record the
failure and carry on */
- $this->fExceptions[] = new Exception($message,
'FAILURE');
+ $this->fExceptions[] = new
phpUnitException($message, 'FAILURE');
}

function error($message) {
/* report error that requires correction in the
test script
itself, or (heaven forbid) in this testing
infrastructure */
- $this->fExceptions[] = new Exception($message,
'ERROR');
+ $this->fExceptions[] = new
phpUnitException($message, 'ERROR');
$this->fResult->stop(); // [does not work]
}

--
With best regards, Anton Kovalenko.

Discussion


Log in to post a comment.