I have been working on an open source internet jukebox system for a while now. It was originally developed in the java/j2ee framework.
I have recently been considering rewriting the web portion of this project in PHP5.
The new object model of php5 provides true object oriented programming ability. I like this as I am used to developing in java. I like that i am able to easily apply my existing knowledge of java design patterns, and that this knowledge translates well to php5. I.e. I have been writing my own sort of mini collections and OO database wrapper apis.
Eventually this brought me to the question of how to test my code. Under java i had used JUnit. Was there something like this for php?
Enter PHPUnit:
The unit testing framework rocks.
It is based on JUnit and very similar to work with.
If you are a php developer and designing your current app with OO code, you should definitely check this out:
www.phpunit.de/en/index.php
I have recently been considering rewriting the web portion of this project in PHP5.
The new object model of php5 provides true object oriented programming ability. I like this as I am used to developing in java. I like that i am able to easily apply my existing knowledge of java design patterns, and that this knowledge translates well to php5. I.e. I have been writing my own sort of mini collections and OO database wrapper apis.
Eventually this brought me to the question of how to test my code. Under java i had used JUnit. Was there something like this for php?
Enter PHPUnit:
The unit testing framework rocks.
It is based on JUnit and very similar to work with.
If you are a php developer and designing your current app with OO code, you should definitely check this out:
www.phpunit.de/en/index.php
posted by:
|
|
Unsubscribed |
-
Re: Unit Testing in PHP5 !
Thu, September 1, 2005 - 11:21 PM -
-
Unsu...
Re: Unit Testing in PHP5 !
Fri, September 2, 2005 - 11:35 AMHmm.. looking at the documentation its more like junit than the other phpunit.
I might have to switch to this one. -
-
Unsu...
Re: Unit Testing in PHP5 !
Sat, September 3, 2005 - 1:07 PMThis phpunit framework is NOT happy with php5.
( phpunit.sourceforge.net )
It is written in php4 syntax, and geared towards php4, with a few lines of code half assedly geared towards php5.
I dont think its been tested under php5 at all, as it redeclares the Exception class that is preexisting in php5.
When you try to run a test - this causes things to crash and burn:
Fatal error: Cannot redeclare class exception in /usr/local/lib/phpunit/phpunit.php on line 55
I'm going back to the phpunit from pear :-)
-
-
Re: Unit Testing in PHP5 !
Sun, September 4, 2005 - 12:03 PMI'm using a version which we retrofit for the Gallery project, which I develop on. I know that works in PHP5 just fine, as that's what I develop with. I've even copied this version for use at work.
cvs.sourceforge.net/viewcvs....punit.inc -
-
Unsu...
Re: Unit Testing in PHP5 !
Sun, September 4, 2005 - 12:19 PMYeah that looks more promising.
Tho i went back to using struts/velocity/hibernate for the particular project im working on. I dont have to rewrite junit, velocity and struts are mature code base.
-
-
Re: Unit Testing in PHP5 !
Mon, July 16, 2007 - 6:13 AMI solved easy the problem changing the definition of Exception to Exception1 and then use it on line 266 of phpunit.php.
Diffing the changes:
55
< class Exception {
> class Exception1 {
266
< $this->fExceptions[] = new Exception(&$message, 'FAILURE');
> $this->fExceptions[] = new Exception1(&$message, 'FAILURE');
-
-
Re: Unit Testing in PHP5 !
Mon, July 16, 2007 - 6:14 AMI forgot to say I'm using version 0.5 of phpunit.
-
-
-
-
-
Re: Unit Testing in PHP5 !
Mon, July 16, 2007 - 9:44 PMI use symfony on most oop projects and its unit tests utilize lime. see excerpt from the symfony blog below. I use this jsut because its built in and im too lazy to replace it since it does what i need quite well. I dont know how well it works outside of sf, but i thought id mention it.
You can grab it from the svn... svn.symfony-project.com/trunk/...or/lime
<<
New testing framework
If you keep an eye on the timeline, you probably saw that the symfony unit tests have been completely reworked lately. This is because we switched from simpletest, which was fine but had side effects when functional tests were executed all at once, to our own testing framework, lime.
Lime is more lighweight than PHPUnit or simpletest and has several advantages. First, it launches test files in a sandbox to avoid strange effects between each test file run (one of the reasons we were unable to fix the old symfony core tests). It also introduces a new sfBrowser, sfTestBrowser and more importantly sfDomCssSelectorBrowser that allow you to write functionnal tests with ease. It is not backward compatible but is a lot more powerful than the old system. Oh, and it holds in a single file, lime.php, without any dependence.
>>
