Test Skeleton generator
, (*1)
Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template), (*2)
CHANGELOG!, (*3)
Installation
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require -dev --prefer-dist insolita/yii2-skeletest "~1.1"
or add, (*6)
"insolita/yii2-skeletest": "~1.1"
to the require-dev section of your composer.json
file., (*7)
Usage
in console application config add to controllerMap section, (*8)
'skeletest'=>[
'class'=>\insolita\skeletest\controllers\SkeletestController::class,
'apps' => [
//register each application with own test directory - for basic template like this
'app'=>[
'appPath' => '@app/',
'testPath' => '@app/tests/codeception/unit',
'testNs' => 'tests\codeception\unit',
'testerNs' => 'tests\codeception\UnitTester', //optional
]
],
'app'=>'app',//default application key
'templateFile' => '@vendor/insolita/yii2-skeletest/templates/codeception.php', //or own template
'overwrite' => false, //overwrite existed test
'ignoreGetters' => true, //skip getter methods
'ignoreSetters' => true, //skip setter methods
'withProtectedMethods' => false, //include protected methods in test skeleton
'withPrivateMethods' => false,//include private methods in test skeleton
'withStaticMethods' => true,//include static methods in test skeleton
'ignoreFilePatterns'=>['~(controllers|widget|asset|interface|contract|migration)~i'],//array of regexp patterns for skip files
'ignoreMethodPatterns'=>['~^(behaviors|find|rules|tableName|attributeLabels|scenarios)$~'],//array of regexp patterns for skip methods
],
after configuration you can use it in console, (*9)
- generate single test by file alias
./yii skeletest @app/components/MyComponent.php
- generate tests recursive for all files by directory alias (Be careful, if directory contains sub-directory with non-psr namespace roots, for that directories you must generate test directly)
./yii skeletest/dir @frontend/services/registration --app=front
- show options
./yii help skeletest/file
Template customization
Copy @vendor/insolita/yii2-skeletest/templates/codeception.php in any project directory and modify as you want
Change in controllerMap 'templateFile' parameter of skeletest controller to you own template path
Share in issue usefull template variants, (*10)