Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template)
The preferred way to install this extension is through composer.
Either run
php composer.phar require -dev --prefer-dist insolita/yii2-skeletest "~1.1"
or add
"insolita/yii2-skeletest": "~1.1"
to the require-dev section of your composer.json
file.
in console application config add to controllerMap section
'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
./yii skeletest @app/components/MyComponent.php
./yii skeletest/dir @frontend/services/registration --app=front
./yii help skeletest/file
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
0.0.1 - initial upload
1.0 - first release
1.1 rewrited;
added best support for non-psr alias;
changed property 'pathMap' to 'apps';
templates update, render template parameteres was changed!,access to class reflection in templates
test covers and travis-ci integration
Comments