views:

482

answers:

1

I'm just starting to try out phpunit on some existing code. The naming convention we use is that the MyClass class should be in MyClass.class.php. PHPUnit seems to require that the file should be called MyClass.php.

Is there any way around this?

I noticed it while trying to generate a skeleton test class:

phpunit --skeleton-test MyClass.class

PHPUnit 3.3.4 by Sebastian Bergmann.

Could not find class "MyClass.class" in "/home/jd/skeleton/classes/MyClass.class.php".
Fatal error: Call to a member function getOutClassName() on a non-object in /usr/share/php/PHPUnit/TextUI/Command.php on line 470
+3  A: 

Its not a requirement, its just assumptive. You can write your own test-cases.

Skeleton just makes a mock-up one "the easy way" that makes dummy functions for all your classes dummy functions.

Also,

phpunit --skeleton-test MyClass  MyClass.class.php

Might do what you want.

   Usage: phpunit [switches] UnitTest [UnitTest.php]
       phpunit [switches] <directory>

--skeleton-class         Generate Unit class for UnitTest in UnitTest.php.
--skeleton-test          Generate UnitTest class for Unit in Unit.php.

so by that reasoning, if you don't tell it what file the class is in it will try guess, if you do tell it what file the class is in, it wont guess.

Kent Fredric
Thanks. If I had a brain I'd be dangerous.
J.D. Fitz.Gerald