I’m a longtime Java programmer working on a PHP project, and I’m trying to get PHPUnit up and working. When unit testing in Java, it’s common to put test case classes and regular classes into separate directories, like this –
/src MyClass.java /test MyClassTest.java
and so on.
When unit testing with PHPUnit, is it common to follow the same directory structure, or is there a better way to lay out test classes? So far, the only way I can get the ‘include(‘MyClass.php’)’ statement to work correctly is to include the test class in the same directory, but I don’t want to include the test classes when I push to production.
I think it’s a good idea to keep your files separate. I normally use a folder structure like this:
In your case, for including the class in your test file, why not just pass the the whole path to the include method?
or