{"id":24350134,"url":"https://github.com/gealex/doublit","last_synced_at":"2026-05-21T03:31:58.919Z","repository":{"id":62509432,"uuid":"141801134","full_name":"gealex/doublit","owner":"gealex","description":"Double and test PHP classes easily in PhpUnit","archived":false,"fork":false,"pushed_at":"2019-06-04T10:57:24.000Z","size":174,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-18T09:30:10.293Z","etag":null,"topics":["mock","mocking","php","phpunit","test","test-doubles","testing","testing-tools","unit-test","unit-testing"],"latest_commit_sha":null,"homepage":"https://getdoublit.com","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/gealex.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-07-21T10:03:06.000Z","updated_at":"2023-11-10T08:48:51.000Z","dependencies_parsed_at":"2022-11-02T13:01:10.575Z","dependency_job_id":null,"html_url":"https://github.com/gealex/doublit","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gealex%2Fdoublit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gealex%2Fdoublit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gealex%2Fdoublit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gealex%2Fdoublit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gealex","download_url":"https://codeload.github.com/gealex/doublit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243150322,"owners_count":20244367,"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","mocking","php","phpunit","test","test-doubles","testing","testing-tools","unit-test","unit-testing"],"created_at":"2025-01-18T13:27:08.141Z","updated_at":"2025-12-28T06:10:55.426Z","avatar_url":"https://github.com/gealex.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doublit - Double and test PHP classes easily in PhpUnit\n\n[![Build Status](https://travis-ci.org/gealex/doublit.svg?branch=master)](https://travis-ci.org/gealex/doublit)\n\nDoublit can help you to test your PHP classes by generating doubles that look like the original classes but can be manipulated and tested (sort of a copy of a class). These doubles then can then be used instead of the original classes for your test. Doublit can create doubles of any kind of class, interface or trait. \n\nSee full documentation at [https://getdoublit.com](https://getdoublit.com)\n\n\n## Installation\n\nAdd the line `\"gealex/doublit\": \"~2.1.0\"` in the `\"require-dev\"` section of your composer.json file :\n    \n    {\n        \"require-dev\": {\n            \"gealex/doublit\": \"~2.1.0\"\n        }\n    }\n\nAnd run the following command :\n    \n    $ composer update\n    \nThis will install the latest version of Doublit with the required PhpUnit package.\n\n## Creating a double\n\nA double is called a \"dummy\" when all the methods of the original class are overwritten to return `null`. To get a \"dummy\" double instance, use the `dummy` method :\n\n    ```php\n    // Get a double instance of type \"dummy\" for class \"MyClass\"\n    $my_double = Doublit::dummy(MyClass::class)-\u003egetInstance();\n    ```\n\nA double is called a \"mock\" when all the methods of the original class are overwritten to behave the same as in the original class. To get a \"mock\" double instance, use the `mock` method :\n   \n    ```php\n    // Get a double instance of type \"mock\" for class \"MyClass\"\n    $my_double = Doublit::mock(MyClass::class)-\u003egetInstance();\n    ```\n   \nFor more details : [Read the doc on creating doubles](doc/creating_doubles.md)\n\n## Testing a double\nTo test how many times a double method is called, use the `count` method :\n    \n    ```php\n    // Test that the method \"myMethod\" is called a least one time\n    $double::_method('myMethod')-\u003ecount('\u003e=1');\n    ```\n\nTo test the values of the arguments passed to a double method, use the `args` method :\n\n    ```php\n    // Test that the arguments passed to method \"myMethod\" are \"value1\" and \"value2\"\n    $double::_method('myMethod')-\u003eargs(['value1', 'value2']);\n    ```\n\nTo change the return value of a method, use the `stub` method. :\n    \n    ```php\n    // Make method \"myMethod\" return \"hello\"\n    $my_double::_method('myMethod')-\u003estub('hello');\n    ```\n\nFor more details : [Read the doc on testing doubles](doc/testing_doubles.md)\n\n## Configuration\n\nYou define the configuration for a specific double using the 2nd argument of the `dummy` and `mock` methods :\u003c/p\u003e\n\n    ```php\n    // Get double instance with config\n    $my_double = Doublit::dummy(MyClass::class, [\n        'allow_final_doubles' =\u003e true,\n        'allow_non_existent_classes' =\u003e true\n    ])-\u003egetInstance();\n    ```\n\t\nHere is a list of all available config parameters :\n\n- `allow_final_doubles` : Set this parameter to `false` to stop Doublit from trying to make doubles of final classes/methods.\n- `allow_protected_methods` : Set this parameter to `false` to disallow testing protected methods.\n- `allow_non_existent_classes` : Set this parameter to `false` to disallow alias doubles of non existent classes.\n- `test_unexpected_methods` : Set this parameter to `true` to automatically receive an assertion error whenever an unexpected method is called.\n \nFor more details : [Read the doc on configuration](doc/configuration.md)\n\n## About\n\n### License\nDoublit is licensed under the [MIT license](https://opensource.org/licenses/MIT).\n\n### Author\nAlexandre Geiswiller - [alexandre.geiswiller@gmail.com](mailto:alexandre.geiswiller@gmail.com).\n\nFor more details : [Read the doc on about](doc/about.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgealex%2Fdoublit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgealex%2Fdoublit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgealex%2Fdoublit/lists"}