{"id":20705143,"url":"https://github.com/xepozz/test-it","last_synced_at":"2025-04-23T01:31:52.629Z","repository":{"id":65467955,"uuid":"591430663","full_name":"xepozz/test-it","owner":"xepozz","description":"A tool for generating files with tests cases based on class methods signatures.","archived":false,"fork":false,"pushed_at":"2023-03-02T23:10:48.000Z","size":329,"stargazers_count":18,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T20:51:10.278Z","etag":null,"topics":["php","testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xepozz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-20T18:34:35.000Z","updated_at":"2024-05-03T09:40:07.000Z","dependencies_parsed_at":"2023-02-14T12:01:02.058Z","dependency_job_id":null,"html_url":"https://github.com/xepozz/test-it","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xepozz%2Ftest-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xepozz%2Ftest-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xepozz%2Ftest-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xepozz%2Ftest-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xepozz","download_url":"https://codeload.github.com/xepozz/test-it/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250352358,"owners_count":21416478,"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":["php","testing"],"created_at":"2024-11-17T01:16:21.773Z","updated_at":"2025-04-23T01:31:52.608Z","avatar_url":"https://github.com/xepozz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test it!\n\nA tool for generating files with tests cases based on class methods signatures.\n\n### Installation\n\n```shell\ncomposer require xepozz/test-it --dev\n```\n\n### Usage\n\nRun the script from the console and pass `source` directory and `target` directory by your needs.\nDefault values are `src` and `tests` respectively.\n\n```shell\n./vendor/bin/test-it src tests\n```\n\n### Description\n\nThe package reads all `.php` files from the `source` directory, analyses it and \ncreates files mirrored by the relative path to `source` directory in `target` directory.\n\nThe tool respects parameters types and methods return value and generates all possible test cases.\n\n### Example\n\nInput: \n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Xepozz\\TestIt\\Tests\\Integration\\OneParameter\\src;\n\nclass UserController\n{\n    public function inverse(bool $value): bool\n    {\n        return !$value;\n    }\n}\n```\n\nOutput:\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Xepozz\\TestIt\\Tests\\Integration\\OneParameter\\tests;\n\nuse Xepozz\\TestIt\\Tests\\Integration\\OneParameter\\src\\UserController;\n\nfinal class UserControllerTest extends \\PHPUnit\\Framework\\TestCase\n{\n    /**\n     * @dataProvider dataProviderInverse\n     */\n    public function testInverse(bool $expectedValue, bool $valueValue): void\n    {\n        // arrange\n        $userController = new UserController();\n\n        // act\n        $actualValue = $userController-\u003einverse($valueValue);\n\n        // assert\n        $this-\u003eassertEquals($expectedValue, $actualValue);\n    }\n\n\n    public static function dataProviderInverse(): iterable\n    {\n        yield [false, true];\n        yield [true, false];\n    }\n}\n```\n\nAs we can see it generates a `dataProvider` related to a function, evaluates return values and saves it to the data provider function.\n\n### Config file\n\nCreate a file with name `test-it.php` in project root if you need to configure generation process and configure the config as you wish.\n\nHere is an example of possible options to configure:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Xepozz\\TestIt\\Config;\n\nreturn function (Config $config) {\n    $config\n        // disabled results substitution\n        -\u003eevaluateCases(false)\n        // sets a directory to scan\n        -\u003esetSourceDirectory('src')\n        // excludes particular files from scanning\n        -\u003eexcludeFiles([\n            __DIR__ . '/src/Kernel.php',\n        ])\n        // excludes particular directories and all child directories from scanning\n        -\u003eexcludeDirectories([\n            __DIR__ . '/src/Asset',\n            __DIR__ . '/src/Controller',\n            __DIR__ . '/src/View',\n        ])\n        // includes subdirectories when parent directories were ignored\n        -\u003eincludeDirectories([\n            __DIR__ . '/src/Controller/DTO',\n        ]);\n};\n```\n\n\u003e Passing command arguments does not make any changes the config\n\n### Help\n\nCall the script with the flag `--help` to see all the possible options.\n\n```shell\n./vendor/bin/test-it --help\n```\n```\nUsage:\n./test-it [\u003csource\u003e [\u003ctarget\u003e]]\n\nArguments:\nsource                The directory that will be processed [default: \"src\"]\ntarget                The output directory where tests will be placed [default: \"tests\"]\n\nOptions:\n-h, --help            Display help for the given command. When no command is given display help for the ./test-it command\n-q, --quiet           Do not output any message\n-V, --version         Display this application version\n--ansi|--no-ansi  Force (or disable --no-ansi) ANSI output\n-n, --no-interaction  Do not ask any interactive question\n-v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n```\n\n### Additional documentation\n\n- [Test case evaluation](/docs/test-case-evaluation.md)\n\n### Roadmap\n\n- [ ] Mock classes creation\n- [ ] Support multiple test methods names strategies (`test_function_name` and `testFunctionName`)\n- [ ] Test constant expression when a method always returns the same result\n- [ ] Add benchmarks\n- [ ] Add static analyzer\n- [ ] Add exclusion list\n  - [X] Paths (directories, files)\n  - [X] Classes\n  - [ ] Inheritance tree (interfaces, parent classes)\n- [ ] Override config with command arguments\n- [ ] Add Codeception support\n\n### Restrictions\n\nIt doesn't work with not namespaced classes.\n\nIt has only one test method name generation strategy. See the roadmap.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxepozz%2Ftest-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxepozz%2Ftest-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxepozz%2Ftest-it/lists"}