Cradle
0.3.3
Simple library for creating Web-based applications
|
Digger simple automatic generator of PHPUnit tests. More...
Public Member Functions | |
__construct ($config=NULL, $generateNow=false) | |
stripFunctionParams ($stringParams) | |
generateCode ($sourceCode, $sourceFileName="", $resultFileName="NonameClass", $currentContent=NULL) | |
generateFile ($sourceFile, $outFile) | |
generate ($config=NULL) | |
getResult () | |
generateRunFile ($destinations, $destinationRoot) | |
Static Public Member Functions | |
static | placeAfter ($sourceText, $newText, $findPattern=NULL, $afterKeys=array('<\?php')) |
Data Fields | |
$testClassName = "[NAME]Test" | |
$testName = "test_[NAME]" | |
$excludeNames = [ "^__" ] | |
$testNameSpace = "" | |
$templateHeader | |
$templateComments | |
$templateClass | |
$templateTest | |
$sourcePaths = [ "./" ] | |
$sourcePatterns = [ '\.php$' ] | |
$sourceExclude = [ '^_', 'Test\.php$' ] | |
$sourceRecursive = true | |
$destinationRoot = "./tests" | |
$includeRelativePath = true | |
$destinationTree = true | |
$testFileName = "[NAME]Test.php" | |
$runFileName = "run.sh" | |
$phpUnitFile = "phpunit" | |
$runFileHeaderTemplate | |
$runFileLineTemplate | |
$includeAutoloaderFileName = "" | |
Digger simple automatic generator of PHPUnit tests.
Generates PHPUnit test skeletons for PHP files with classes and functions.
Exception |
__construct | ( | $config = NULL , |
|
$generateNow = false |
|||
) |
Class constructor
hash | string | $config | Hash array with values of class properties, or config file name contains it. |
boolean | $generateNow | Generate tests on create. |
generate | ( | $config = NULL | ) |
generateCode | ( | $sourceCode, | |
$sourceFileName = "" , |
|||
$resultFileName = "NonameClass" , |
|||
$currentContent = NULL |
|||
) |
Generate code with PHPUnit tests for classes and functions of source code
string | $sourceCode | PHP-file source code. |
string | $sourceFileName | (Option) needed to create "require" directive. |
string | $resultFileName | (Option) needed to create class name for stanalong functions and to create "require" directive with relative path. |
string | $currentContent | (Option) needed to insert result code inside an existing content. |
generateFile | ( | $sourceFile, | |
$outFile | |||
) |
Generate file with PHP-unit tests
string | $sourceFile | Input file name. |
string | $outFile | Output file name. |
Exception |
generateRunFile | ( | $destinations, | |
$destinationRoot | |||
) |
Generate common file body to execute all tests
array | $destinations | List of destination file names. |
string | $destinationRoot | Root path for destinations. |
getResult | ( | ) |
Returns a result of generation
|
static |
To place a some new text into the source text after a first found "key pattern"
string | $sourceText | A source text. |
string | $newText | A new text to insert. |
string | $findPattern | Regular expression to find duplicates of $newText and to cancel insertion. If $findPattern=NULL $newText will inserted without check and duplicate may occur. |
array | $afterKeys | The $newText will inserted after first found "key pattern" from $afterKeys patterns. |
stripFunctionParams | ( | $stringParams | ) |
Strip function parameters. To clear any symbols befor "$paramName" (such as '&' or 'typeOfParameter')
string | $stringParams | String of function parameters. |
$destinationRoot = "./tests" |
string Root of destination path
$destinationTree = true |
boolean Create output sub directories
$excludeNames = [ "^__" ] |
string Array of regular expressions to exclude some methods (such as: __construct, __destruct, and so on ...)
$includeAutoloaderFileName = "" |
string Include 'requrie_once' directive in out test file
$includeRelativePath = true |
boolean Use relative path of source file in "include_once" directive
$phpUnitFile = "phpunit" |
string PHPUnit exec file
$runFileHeaderTemplate |
string Template for output run file
$runFileLineTemplate |
string Template for output run file line
$runFileName = "run.sh" |
string Run file name
$sourceExclude = [ '^_', 'Test\.php$' ] |
array Array of regexp patterns to exclude some file names
$sourcePaths = [ "./" ] |
array Source paths to find all source files
$sourcePatterns = [ '\.php$' ] |
array Array of regexp patterns to find only necessary file names
$sourceRecursive = true |
boolean Searching for source files recursively
$templateClass |
string Class body template for output PHP file
$templateComments |
string Template for some system comments
$templateHeader |
string Header template for output PHP file
$templateTest |
string Class method/function body template for output PHP file
$testClassName = "[NAME]Test" |
string Class name template for test
$testFileName = "[NAME]Test.php" |
string Template for file name of test
$testName = "test_[NAME]" |
string Method name template for test
$testNameSpace = "" |
string Namespace for test