{"id":23506989,"url":"https://github.com/timesplinter/proxy-mock","last_synced_at":"2025-04-16T02:19:24.960Z","repository":{"id":57069876,"uuid":"96175524","full_name":"TiMESPLiNTER/proxy-mock","owner":"TiMESPLiNTER","description":null,"archived":false,"fork":false,"pushed_at":"2019-10-17T13:29:51.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-16T02:19:00.909Z","etag":null,"topics":["mock","php","phpunit","proxy","testing"],"latest_commit_sha":null,"homepage":null,"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/TiMESPLiNTER.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-07-04T04:34:33.000Z","updated_at":"2020-01-16T18:20:49.000Z","dependencies_parsed_at":"2022-08-24T14:54:19.613Z","dependency_job_id":null,"html_url":"https://github.com/TiMESPLiNTER/proxy-mock","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TiMESPLiNTER%2Fproxy-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TiMESPLiNTER%2Fproxy-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TiMESPLiNTER%2Fproxy-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TiMESPLiNTER%2Fproxy-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TiMESPLiNTER","download_url":"https://codeload.github.com/TiMESPLiNTER/proxy-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183413,"owners_count":21226196,"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","phpunit","proxy","testing"],"created_at":"2024-12-25T10:14:00.605Z","updated_at":"2025-04-16T02:19:24.944Z","avatar_url":"https://github.com/TiMESPLiNTER.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"ProxyMock\n=========\n\n**THIS PACKAGE IS ABANDONNED**\n\nTo replace a service of the Symfony container with a mock make a public alias on the service and then you're able to set\na mock for it in the test case (if you have access to the container which is the case in ̀Symfony's `KernelTestCase`).\n\n**config/services.yaml**\n```\nservices:\n    my.service:\n        class: My\\Service\n```\n\n**config/services_test.yaml**\n```\nservices:\n    my.service.test:\n        alias: my.service\n        public: true\n```\n\n**Your test case `extends KernelTestCase`**\n```php\nuse My\\Service;\nuse Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase;\n\nfinal class ConsumeUserMessagesFromCoreTest extends KernelTestCase\n{\n    public function testSomething(): void\n    {\n        // Access the service over the public alias defined in \"services_test.yaml\"\n        self::$container-\u003eset('my.service.test', $this-\u003egetMockBuilder(Service::class)-\u003egetMock());\n    }\n}\n```\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/TiMESPLiNTER/proxy-mock/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/TiMESPLiNTER/proxy-mock/?branch=master)\n\nThis library helps to create a proxy instance of a class which then can hold a PHPUnit\nmock of it. That way you can manipulate the mock which sits inside the proxy class but\nnever have to change the proxy class.\n\nThis can be useful for example in cases of read-only containers where you can't\noverride services at runtime. (The dependency injection container component of \nSymfony 4 will most likely behave like that.)\n\n```php\nclass Foo { ... }\n\n$factory = new ProxyMockFactory();\n$proxyMock = $factory-\u003ecreate(Foo::class);\n\n// In a PHPUnit test case\n$mock = $this-\u003egetMockBuilder(Foo::class)\n    -\u003edisableOriginalConstructor()\n    -\u003egetMock();\n\n$proxyMock-\u003esetMock($mock);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimesplinter%2Fproxy-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimesplinter%2Fproxy-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimesplinter%2Fproxy-mock/lists"}