PHP Classes

How to Automate the Generation of Files and Directories to Test Project Files With PHPUnit or Codeceptionusing the Package Yii2 SkeleTest: Generate file skeletons to test PHP projects

Recommend this page to a friend!
  Info   View files Documentation   View files View files (22)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-17 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 5 This week: 5All time: 11,302 This week: 12Up
Version License PHP version Categories
yii2-skeletest 1.0MIT/X Consortium ...5PHP 5, Console, Code Generation, Testing
Description 

Author

This package can generate file skeletons to test PHP projects.

It provides a tool application that can start from the command line console shell to generate and analyze given project files or whole directories of project files.

The tool can generate files with PHP scripts to test the analyzed project files using PHPUnit or Codeception.

Picture of Insolita
  Performance   Level  
Name: Insolita <contact>
Classes: 21 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 15x

Documentation

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

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file, 4 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagecontrollers (1 file)
Files folder imageentity (2 files)
Files folder imageservices (2 files)
Files folder imagetemplates (2 files)
  Plain text file AccessibleMethodTrait.php Class Class source

  Files folder image Files  /  src  /  controllers  
File Role Description
  Plain text file SkeletestController.php Class Class source

  Files folder image Files  /  src  /  entity  
File Role Description
  Plain text file AppConfig.php Class Class source
  Plain text file FileClass.php Class Class source

  Files folder image Files  /  src  /  services  
File Role Description
  Plain text file ReflectionService.php Class Class source
  Plain text file SkeletestService.php Class Class source

  Files folder image Files  /  src  /  templates  
File Role Description
  Accessible without login Plain text file codeception.php Example Example script
  Accessible without login Plain text file codeception2.php Example Example script

  Files folder image Files  /  tests  
File Role Description
Files folder imageconfig (2 files)
Files folder imageunit (3 files)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file bootstrap.php Example Example script
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file yii Example Example script

  Files folder image Files  /  tests  /  config  
File Role Description
  Plain text file base.php Class Class source
  Accessible without login Plain text file console.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file ReflectionServiceTest.php Class Class source
  Plain text file SkeletestServiceTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:5
This week:5
All time:11,302
This week:12Up