Using PHPUnit
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Using PHPUnit
¡Hola, mundo!
I'm trying to implement PHPUnit in a project of mine. Their site recommends installing in via PEAR. Does that mean any other developers that were to checkout the repository would have to install PHPUnit themselves on their own machine? If so, how does one include the right files for the tests?
¡Muchas gracias, señores!
I'm trying to implement PHPUnit in a project of mine. Their site recommends installing in via PEAR. Does that mean any other developers that were to checkout the repository would have to install PHPUnit themselves on their own machine? If so, how does one include the right files for the tests?
¡Muchas gracias, señores!
Re: Using PHPUnit
This depends whether you want to ship your unit tests with your code or not. If you are building open source project and you want to ship the unit tests, the developers will need to install PHPUnit as well. If you are building a product you'll sell (or distribute free), usually it's shipped without the unit tests.
Or, in another way, if your users are supposed to modify the code, they will need to install PHPUnit to use the unit tests, otherwise you don't need to provide the tests.
Or, in another way, if your users are supposed to modify the code, they will need to install PHPUnit to use the unit tests, otherwise you don't need to provide the tests.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Okay, that's what I was looking for. How do I include the right path in the individual unit tests?
Re: Using PHPUnit
By referencing relative paths and relying on include_path (PEAR code repository is usually listed under include_path):Jonah Bron wrote:Okay, that's what I was looking for. How do I include the right path in the individual unit tests?
Code: Select all
require 'PHPUnit/Framework/TestCase.php';
class SomeTest extends PHPUnit_Framework_TestCase {
// ..........
}
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Aha, excellent. They ought to put that into the documentation 
Thanks.
Thanks.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Hm, /usr/share/php is in include_path, and it contains PHPUnit/. But it doesn't seem to contain the PHPUnit stuff. /usr/share/pear doesn't exist, and /usr/share/php/PEAR doesn't have any PHPUnit stuff either. Here's /usr/share/php/PHPUnit/:
[text] |-Extensions
|---Database
|-----Constraint
|-----DataSet
|-------Persistors
|-------Specs
|-----DB
|-------MetaData
|-----Operation
|-----UI
|-------Mediums
|-------Modes
|---------ExportDataSet
|---SeleniumTestCase
|---Story
|-Framework
|---MockObject
|-----Builder
|-----Generator
|-----Invocation
|-----Matcher
|-----Stub[/text]
[text] |-Extensions
|---Database
|-----Constraint
|-----DataSet
|-------Persistors
|-------Specs
|-----DB
|-------MetaData
|-----Operation
|-----UI
|-------Mediums
|-------Modes
|---------ExportDataSet
|---SeleniumTestCase
|---Story
|-Framework
|---MockObject
|-----Builder
|-----Generator
|-----Invocation
|-----Matcher
|-----Stub[/text]
Re: Using PHPUnit
What kind of stuff you were expecting to see there? The directory structure you posted looks very much like PHPUnit's.But it doesn't seem to contain the PHPUnit stuff.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Well, none of the classes are there that I was expecting. Where is TestCase.php normally in that structure?
Re: Using PHPUnit
/usr/share/php/PHPUnit/Framework/TestCase.phpJonah Bron wrote:Well, none of the classes are there that I was expecting. Where is TestCase.php normally in that structure?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
But it's not there. Just the MockObject/ folder.
Re: Using PHPUnit
Are you sure you have PHPUnit installed? What does show?
Code: Select all
sudo pear list- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Strange, PHPUnit isn't listed. I tried running the install command again, and now it tells me that I need to upgrade from PEAR 1.9.1 to 1.9.2. But I have it installed via Ubuntu repository? Surely they haven't come out with a new version since I updated a few days ago. I'm updating now just in case. Do I have to download and install it manually?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using PHPUnit
Never mind, found the solution on Superuser here: http://superuser.com/questions/55055/
Funny, you have to tell PEAR to update itself through it's own mechanism, and then it work. Ah, the infinite mysteries of software
Funny, you have to tell PEAR to update itself through it's own mechanism, and then it work. Ah, the infinite mysteries of software