PHPUnit File Naming Conventions

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

Is there any way around this?

I noticed this while trying to generate a skeletal 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
source share
2 answers

This is not a requirement, its just an assumption. You can write your own test cases.

The skeleton just makes the layout in the “easy way” that makes dummy functions for all of your dummy functions in your class.

Besides,

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

You can 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.

, , , , , , .

+7

, . phpunit 3.5.6 . phpUnit , , , . , Foo /my/dir, Foo.php, -/my/dir/Foo.php

, Foo :

<?php

namespace my\space;
class Foo
{
    ...
}

, , , Foo.php, :

user[/my/dir]$ phpunit --skeleton-test my\\dir\\Foo Foo.php

. , phpUnit , . , -.

0

Source: https://habr.com/ru/post/1699558/


All Articles