insolita/yii2-skeletest Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template)

extensioncodeceptionphpunittests

Test Skeleton generator

Status Latest Stable Version Total Downloads License

Generate test skeletons for file or whole directory with target file methods (codeception/phpunit - based on template)

CHANGELOG!

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

Changelog

  • 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

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.1.0 is the latest of 4 releases



MIT license
Stats
3 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
178 total downloads