{"id":20674642,"url":"https://github.com/alexyav/unitgen","last_synced_at":"2025-04-19T20:27:03.950Z","repository":{"id":43631391,"uuid":"71730603","full_name":"AlexyAV/unitgen","owner":"AlexyAV","description":"Unit tests skeleton generator.","archived":false,"fork":false,"pushed_at":"2016-10-24T09:46:06.000Z","size":42,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T12:51:25.652Z","etag":null,"topics":["code-generator","phpunit"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexyAV.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-23T21:23:44.000Z","updated_at":"2019-07-30T10:26:51.000Z","dependencies_parsed_at":"2022-08-25T19:40:10.043Z","dependency_job_id":null,"html_url":"https://github.com/AlexyAV/unitgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyAV%2Funitgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyAV%2Funitgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyAV%2Funitgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexyAV%2Funitgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexyAV","download_url":"https://codeload.github.com/AlexyAV/unitgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249793905,"owners_count":21326626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","phpunit"],"created_at":"2024-11-16T21:06:31.899Z","updated_at":"2025-04-19T20:27:03.930Z","avatar_url":"https://github.com/AlexyAV.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unitgen\n[![Build Status](https://travis-ci.org/AlexyAV/unitgen.svg?branch=master)](https://travis-ci.org/AlexyAV/unitgen)\n[![Code Climate](https://codeclimate.com/github/AlexyAV/unitgen/badges/gpa.svg)](https://codeclimate.com/github/AlexyAV/unitgen)\n[![Test Coverage](https://codeclimate.com/github/AlexyAV/unitgen/badges/coverage.svg)](https://codeclimate.com/github/AlexyAV/unitgen/coverage)\n\nThe generator of the basic structure for the unit tests. The generated classes are based on tests [phpunit](https://phpunit.de) version \u003e= 5.4.*.\nUnitgen is is a command line tool that recursively(optional) analyze the specified path and generates unit test files. The directory structure is reproduced according to the original structure.\n\n## Installation\n\nInstallation via [Composer](https://getcomposer.org/). Add to your composer.json file.\n```\n{\n    \"require-dev\": {\n        \"phpunit/phpunit\": \"5.4.*\",\n        \"unitgen/unitgen\": \"dev-master\"\n    }\n}\n```\n\n## Examlpe of created test\n\nFor source class \"SourceClass\":\n\u003cpre lang=\"php\"\u003e\nnamespace source\\class\\path;\n\nclass SourceClass\n{\n    /**\n     * @throws \\Exception\n     */\n    public function bar()\n    {\n        ...\n    }\n}\n\u003c/pre\u003e\nWill be generated next structure within \"SourceClassTest\":\n\u003cpre lang=\"php\"\u003e\nuse PHPUnit\\Framework\\TestCase;\n\nclass SourceClassTest extends TestCase\n{\n    private $sourceClass;\n    \n    public function setUp()\n    {\n        $this-\u003esourceClass = new \\source\\class\\path\\SourceClass();\n    }\n    \n    public function testBar()\n    {\n        \"//TODO Implement test for bar method\\n\";\n        $this-\u003eassertTrue(false);\n    }\n    \n    public function testBarException()\n    {\n        \"//TODO Implement test for bar method\\n\";\n        $this-\u003eexpectException(\\Exception::class);\n    }\n    \n    public function tearDown()\n    {\n        \"//TODO Implement tearDown method\";\n    }\n}\n\u003c/pre\u003e\nUnitgen generates test method for public method only. Also it looks for annotation exception data and generates appropriate test methods.\n\nNOTE: Unitgen does not affect existing files.\n\n## Configuration\nFor use unitgen you should specify a configuration file.\n\nHere is an exaple of configuration file with all available options:\n\u003cpre lang=\"php\"\u003e\nreturn [\n    'source'        =\u003e [\n        'path'    =\u003e [], // required\n        'exclude' =\u003e []\n    ],\n    'savePath'      =\u003e '', // required\n    'classExclude'  =\u003e [\n        'name'      =\u003e [], // array of full class names\n        'regexp'    =\u003e [], // array of reqular expressions\n        'parent'    =\u003e [], // array of parent classes\n        'implement' =\u003e [], // array of interfaces\n    ],\n];\n\u003c/pre\u003e\n\n| Name | Description | Required | Example | Type |\n|--------------|--------------------------------------------------------------------------------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------|--------|\n| path | Specified source path directory. Unitgen will walk throught recursively(optional) and generate corresponding test files. Boolean value specifies to walk recursively. | true | [     'first-source-path'      =\u003e true,     'second-source-path' =\u003e false ] | array |\n| exclude | Directories that will be excluded from source path. | false | ['second-source-path'] | array |\n| savePath | Writable path to save generated tests. Must already exist. | true | 'generated-test-path' | string |\n| classExclude | Classes that will be excluded from source path. | false | 'name'=\u003e [Examle::class], 'regexp'=\u003e ['/^Controller.*/'], 'parent'=\u003e [\\Exception::class],  'implement' =\u003e [\\Iterator::class], | array |\n\n## Example of usage\n\n```\n$ cd \"vendor/.../unitget/bin\"\n\n$ ./unitgen run \"config-path\"\n\nStart test generation.\n======================\n\nGeneration completed successful.\n-------------------------\nNumber of files in source path: 9\nNumber of generated test classes: 3\n-------------------------\nGenerated in:0.12969493865967\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexyav%2Funitgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexyav%2Funitgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexyav%2Funitgen/lists"}