{"id":16233795,"url":"https://github.com/cawolf/phpstorm-quick-mock","last_synced_at":"2025-03-19T14:31:44.739Z","repository":{"id":33519259,"uuid":"150024450","full_name":"cawolf/phpstorm-quick-mock","owner":"cawolf","description":"PHPStorm plugin allowing you to quickly create mock objects from within a test class","archived":false,"fork":false,"pushed_at":"2025-02-25T11:59:26.000Z","size":11691,"stargazers_count":3,"open_issues_count":14,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T19:21:13.903Z","etag":null,"topics":["mock","php","phpstorm-plugin","phpunit","prophecy","testing"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/cawolf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-23T20:50:21.000Z","updated_at":"2022-12-14T22:53:25.000Z","dependencies_parsed_at":"2024-01-18T18:30:43.852Z","dependency_job_id":"18d64296-cfa9-4421-b6c6-4025bf5ee096","html_url":"https://github.com/cawolf/phpstorm-quick-mock","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawolf%2Fphpstorm-quick-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawolf%2Fphpstorm-quick-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawolf%2Fphpstorm-quick-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawolf%2Fphpstorm-quick-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cawolf","download_url":"https://codeload.github.com/cawolf/phpstorm-quick-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997127,"owners_count":20380981,"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":["mock","php","phpstorm-plugin","phpunit","prophecy","testing"],"created_at":"2024-10-10T13:13:56.734Z","updated_at":"2025-03-19T14:31:43.074Z","avatar_url":"https://github.com/cawolf.png","language":"Kotlin","readme":"# Quick Mock\n[![Tests](https://github.com/cawolf/phpstorm-quick-mock/actions/workflows/test.yml/badge.svg)](https://github.com/cawolf/phpstorm-quick-mock/actions/workflows/test.yml)\n[![Version](https://img.shields.io/jetbrains/plugin/v/11165?label=version)](https://plugins.jetbrains.com/plugin/11165-quick-mock)\n[![Downloads](https://img.shields.io/jetbrains/plugin/d/11165)](https://plugins.jetbrains.com/plugin/11165-quick-mock)\n\nPHPStorm plugin allowing you to quickly create mock objects from within a test class\n\nWhen writing tests for classes with constructor dependencies (e.g. every composed service in a DI framework like\n[Symfony](https://symfony.com/)), it is a tedious job to mock these dependencies. While \"Live Templates\" and \"File \nTemplates\" can help with the test case skeleton, the actual class dependencies have to be mocked manually.\n\nNow, you can use this PHPStorm plugin to automatically generate mocks for these dependencies. Place your cursor in the empty\nconstructor argument list, trigger code intentions (default: `ALT + ENTER`) and select `Quick Mock: add constructor prophecies` - done!\n\n## Install\nInstall the plugin by going to `Settings -\u003e Plugins -\u003e Marketplace` and then search for `Quick Mock`\n\n## Options\nYou can configure the plugin under `Languages and Frameworks -\u003e PHP -\u003e Quick Mock`. Available options:\n\n* add DocBlock for generated members: if checked, a DocBlock will be generated for generated mock members\n\n## Usage\nLet's assume you have this business service:\n\n\n    use Psr\\Log\\LoggerInterface;\n    use Symfony\\Component\\Routing\\RouterInterface;\n\n    class Subject\n    {\n        /** @var LoggerInterface */\n        private $logger;\n        /** @var RouterInterface */\n        private $router;\n    \n        public function __construct(LoggerInterface $logger, RouterInterface $router)\n        {\n            $this-\u003elogger = $logger;\n            $this-\u003erouter = $router;\n        }\n        \n        public function doBusinessLogic(string $p1, int $p2, float $p3): string\n        {\n            [...]\n        }\n    }\n    \nWhenever you begin writing a unit test case, you will inevitably come to the subject construction:\n\n\n    use Service\\Subject;\n\n    class SubjectTest extends TestCase\n    {\n        /** @var Subject */\n        private $subject;\n        \n        public function setUp()\n        {\n            $this-\u003esubject = new Subject();\n        }\n        \n        public function testBusinessLogic()\n        {\n            self::assertEquals('expected result', $this-\u003esubject-\u003edoBusinessLogic('parameter 1', 2, 3.0));\n        }\n    }\n\nPlace your cursor anywhere at the `new` expression of a subject under test, trigger code intentions (default: \n`ALT + ENTER`) and select `Quick Mock: add constructor prophecies` - done!\n\n\n    use Psr\\Log\\LoggerInterface;\n    use Service\\Subject;\n    use Symfony\\Component\\Routing\\RouterInterface;\n\n    class SubjectTest extends TestCase\n    {\n        /** @var LoggerInterface */\n        private $logger;\n        /** @var RouterInterface */\n        private $router;\n        /** @var Subject */\n        private $subject;\n    \n        public function setUp()\n        {\n            $this-\u003elogger = $this-\u003eprophesize(LoggerInterface::class);\n            $this-\u003erouter = $this-\u003eprophesize(RouterInterface::class);\n            $this-\u003esubject = new Subject($this-\u003elogger-\u003ereveal(), $this-\u003erouter-\u003ereveal());\n        }\n        \n        public function testBusinessLogic()\n        {\n            self::assertEquals('expected result', $this-\u003esubject-\u003edoBusinessLogic('parameter 1', 2, 3.0));\n        }\n    }\n\n## Issues\nHave a look at https://github.com/cawolf/phpstorm-quick-mock/issues and add your comment or open a new issue.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawolf%2Fphpstorm-quick-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcawolf%2Fphpstorm-quick-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawolf%2Fphpstorm-quick-mock/lists"}