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   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-17 (4 months ago) RSS 2.0 feedNot enough user ratingsTotal: 17 All time: 11,328 This week: 73Up
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.

Innovation Award
PHP Programming Innovation award nominee
April 2024
Number 6
Automated testing is a useful approach to verifying the quality of a software project with less work than if you would test the software manually.

PHP developers can use frameworks like PHPUnit and Codeception to create automated tests faster.

This package can generate skeletons of directories with files to quickly start using PHPUnit or Codeception to create tests for PHP projects.

Manuel Lemos
Picture of Insolita
  Performance   Level  
Name: Insolita <contact>
Classes: 24 packages by
Country: Russian Federation Russian Federation
Age: 38
All time rank: 330890 in Russian Federation Russian Federation
Week rank: 181 Up7 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 17x

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 (22)  
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 (22)  /  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 (22)  /  src  /  controllers  
File Role Description
  Plain text file SkeletestController.php Class Class source

  Files folder image Files (22)  /  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 (22)  /  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 (22)  /  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 (22)  /  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 (22)  /  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 (22)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:17
This week:0
All time:11,328
This week:73Up