Possible to install PHPUnit in a shared hosting account?

i want to start using phpunit to get started learing and using unit testing. i’ve taken one look at the installation instructions http://www.phpunit.de/manual/current/en/installation.html and i have no idea if there’s any point in me even trying or not. as per usual on any of these kind of instructions no concessions or thought is given to shared hosting accounts (e.g. “this will not work in shared hosting accounts”, or “this will work in shared hosting accounts”, or “this might not work in shared hosting accounts, it depends, you need x, y and z. here’s how to see if you’ve got x, y and z”).

is it possible to install phpunit in a shared hosting account?

thanks.

Two things, but not answering your question really …

  1. Use simpletest instead

  2. Just use PHPUnit on your dev machine.

> 1) Use simpletest instead

hmm, ok

> 2) Just use PHPUnit on your dev machine.

that does imply phpunit isn’t good for a shared hosted server, but anyway, does that advice apply to simpletest also? (my shared hosted server is my dev machine)

thanks.

I am not saying that at all, I have never used PHPUnit so I cannot say whether this is the case.

SimpleTest is a library of PHP classes, you just download it and stick it somewhere you can include the main files.

Your dev server is a shared host?

You mean you don’t have a computer sitting in front of you which behaves like a server, or you only work directly on a server editing the files live?

> SimpleTest is a library of PHP classes, you just download it and stick it somewhere you can include the main files.

so there should be no shared host problems possibly

> You mean you don’t have a computer sitting in front of you which behaves like a server, or you only work directly on a server editing the files live?

the machine i run php on is the shared host server.

ok thanks, looks like i should look at simpletest.

If it helps, I’ve found that SimpleTest has been very useful and effective. A technique that I picked up from the xUnit Test Patterns books has also helped a lot.

This is where instead of using test names, a local helper function is used to provide random test values instead.


public function createValue()
{
    return uniqid();
}
public function createNumber()
{
    return rand();
}

which can then be used in the following manner, where $this->model and $this->view are defined in the setUp function:


function testPersonId()
{
    $model = $this->model;
    $view = $this->view;
    $personId = $this->createNumber();
    $profileItem = $this->createValue();
    $view->expectOnce('profileItem', array('ID', $personId));
    $view->setReturnValue('profileItem', $profileItem);
    $this->assertEqual($model->personId($personId), $profileItem);
}

right yup, ok thanks.

i was considering that book you mention but decided not to for some reason which i’ve forgotten now. i got ‘the art of unit testing’ by osherove which looks a much better book for me (beginning with unit testing) apart from its code is .net and it uses nunit. but it looks like, from the first 35 pages i’ve read so far, the .net and nunit aspect isn’t going to be much of a problem.

thanks.

If you are moving up from PHP4 to PHP5, and at the same time learning OOP and simple design patterns, and you want to know about how to Unit test using SimpleTest specifically then a nice relatively cheap book was “PHP Architects guide to PHP Design patterns”.

ok thanks. this osherove book looks like it’s going to cover unit testing really well. looks like a pretty good book. so i’m satisfied so far as unit testing and books go for the moment. thanks.