Search code examples
phpunit-testingtestingsymfony1phpunit

PHPUnit generated test skeleton path


Is it possible to tell phpunit where to put generated test skeleton file by the --skeleton-test command? Even is it possible to tell phpunit to repeat directory structure? Lest say i have file for testing in lib/model/SomeClass.php and i want phpstorm to generate unit test class and put it in test/lib/model/SomeClassTest.php without creation of all neccessary directory structure.

Thanks in advance!


Solution

  • Example reproduced for convenience

    mkdir lib/model tests/lib/model
    echo "<?php class SomeClass{}" > lib/model/SomeClass.php
    

    Calling the code below should do the trick

    phpunit --skeleton-test SomeClass library/model/SomeClass.php SomeClassTest tests/library/model/SomeClassTest.php
    

    The arguments (only the first one being mandatory) are

    $inClassName, 
    $inSourceFile = '',
    $outClassName = '',
    $outSourceFile = ''
    

    as described in the constructor of PHPUnit_Util_Skeleton_Class