insolita / yii2-skeletest
Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template)
Installs: 178
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Type:yii2-extension
Requires
- php: >=7.0
- insolita/yii2-validatorpack: ~0.0.1
- yiisoft/yii2: ~2.0.9
Requires (Dev)
- codeception/codeception: ^2.2.3
- codeception/specify: ~0.4.3
- codeception/verify: ~0.3.1
- nesbot/carbon: ~1.9
- vlucas/phpdotenv: *
This package is not auto-updated.
Last update: 2021-09-10 08:13:29 UTC
README
Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template)
Installation
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.
Usage
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
- 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