{"id":15008347,"url":"https://github.com/idrinth/phpunit-test-generator","last_synced_at":"2025-04-09T16:03:32.908Z","repository":{"id":56989147,"uuid":"118646925","full_name":"Idrinth/phpunit-test-generator","owner":"Idrinth","description":"Generates tests for phpunit","archived":false,"fork":false,"pushed_at":"2024-07-21T17:10:51.000Z","size":1808,"stargazers_count":3,"open_issues_count":12,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-29T16:02:01.783Z","etag":null,"topics":["generator","phpunit","test-generation","unittest"],"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/Idrinth.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":"2018-01-23T17:48:05.000Z","updated_at":"2024-07-21T17:10:55.000Z","dependencies_parsed_at":"2022-08-21T12:50:44.055Z","dependency_job_id":null,"html_url":"https://github.com/Idrinth/phpunit-test-generator","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/Idrinth%2Fphpunit-test-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idrinth%2Fphpunit-test-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idrinth%2Fphpunit-test-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idrinth%2Fphpunit-test-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Idrinth","download_url":"https://codeload.github.com/Idrinth/phpunit-test-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219856268,"owners_count":16556085,"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":["generator","phpunit","test-generation","unittest"],"created_at":"2024-09-24T19:17:44.234Z","updated_at":"2024-10-12T08:41:02.169Z","avatar_url":"https://github.com/Idrinth.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test-Generator for PHPUnit\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cabd3fc70be847d4b2f28c9472598c61)](https://www.codacy.com/app/Idrinth/phpunit-test-generator?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=Idrinth/phpunit-test-generator\u0026amp;utm_campaign=Badge_Grade)\n[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/cabd3fc70be847d4b2f28c9472598c61)](https://www.codacy.com/app/Idrinth/phpunit-test-generator?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=Idrinth/phpunit-test-generator\u0026utm_campaign=Badge_Coverage)\n[![Build Status](https://travis-ci.org/Idrinth/phpunit-test-generator.svg?branch=master)](https://travis-ci.org/Idrinth/phpunit-test-generator)\n[![CodeFactor](https://www.codefactor.io/repository/github/idrinth/phpunit-test-generator/badge)](https://www.codefactor.io/repository/github/idrinth/phpunit-test-generator)\n[![BCH compliance](https://bettercodehub.com/edge/badge/Idrinth/phpunit-test-generator?branch=master)](https://bettercodehub.com/)\n\n## Command \u0026 Options\n\n```\nphp bin/generate-tests --dir=/path/to/alternative/dir --mode=replace\n```\n\n### dir\n\nDir is optional and will default to the current working directory. Pick the directory that the composer.json is in.\n\n### replace (deprecated, see mode)\n\nIf set old testfiles will be overwritten, if not set they will be renamed instead. Usually you shouldn't need this.\n\n### mode\n\nOne of replace, skip or move. Defines how to handle file conflicts and defaults to moving the old file.\n\n### output\n\nIf set will be prepended to the relative paths of dev-autoload paths.\n\n## How does it work?\n\nThe composer.json at the working directory(or the supplied dir) will pe parsed for namespaces(psr 0 and 4), the folders targeted by none-dev namespaces will be searched for classes and test classes will be generated in the appropriate development-autoloading-folder.\nTo determine the testing class to be used, the phpunit dev-dependency is parsed, so you need to supply a constraint to make the generation work.\n\n## Generated Test - Example\n\nThis is a generated testfile for the actual Controller of this library. The intention is to generate PSR2-compatible code, obviously that might not yet be the case everywhere. If you find one where it fails, feel free to file a bug.\n\n```php\n\u003c?php\n\nnamespace De\\Idrinth\\TestGenerator\\Test;\n\nuse PHPUnit\\Framework\\TestCase as TestCaseImplementation;\nuse De\\Idrinth\\TestGenerator\\Controller;\n\n/**\n * this is an automatically generated skeleton for testing Controller\n * @todo actually test\n **/\nclass ControllerTest extends TestCaseImplementation\n{\n    /**\n     * @return Controller\n     * @todo make sure the construction works as expected\n     **/\n    protected function getInstance()\n    {\n        return new Controller(\n            $this-\u003egetMockBuilder('Symfony\\Component\\Finder\\Finder')-\u003egetMock(),\n            $this-\u003egetMockBuilder('De\\Idrinth\\TestGenerator\\Interfaces\\ClassReader')-\u003egetMock(),\n            $this-\u003egetMockBuilder('De\\Idrinth\\TestGenerator\\Interfaces\\ClassWriter')-\u003egetMock(),\n            $this-\u003egetMockBuilder('De\\Idrinth\\TestGenerator\\Interfaces\\Composer')-\u003egetMock(),\n            null\n        );\n    }\n\n    /**\n     * From Controller\n     * @test\n     * @todo replace with actual tests\n     **/\n    public function testInit ()\n    {\n        $instance = $this-\u003egetInstance();\n        $return = $instance-\u003einit();\n\n        $this-\u003eassertInternalType(\n            'object',\n            $return,\n            'Return didn\\'t match expected type object'\n        );\n\n        $this-\u003eassertInstanceOf(\n            'De\\Idrinth\\TestGenerator\\Controller',\n            $return,\n            'Return didn\\'t match expected instance De\\Idrinth\\TestGenerator\\Controller'\n        );\n\n        $this-\u003emarkTestIncomplete(\n            'This test has not been implemented yet.'\n        );\n    }\n\n    /**\n     * From Controller\n     * @test\n     * @todo replace with actual tests\n     **/\n    public function testRun ()\n    {\n        $instance = $this-\u003egetInstance();\n        $return = $instance-\u003erun();\n\n        $this-\u003eassertInternalType(\n            'null',\n            $return,\n            'Return didn\\'t match expected type null'\n        );\n\n        $this-\u003emarkTestIncomplete(\n            'This test has not been implemented yet.'\n        );\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidrinth%2Fphpunit-test-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidrinth%2Fphpunit-test-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidrinth%2Fphpunit-test-generator/lists"}