{"id":20674637,"url":"https://github.com/qratorlabs/smocky","last_synced_at":"2026-02-10T14:02:42.257Z","repository":{"id":62531854,"uuid":"340369408","full_name":"QratorLabs/Smocky","owner":"QratorLabs","description":"Mocker helper based on runkit7","archived":false,"fork":false,"pushed_at":"2025-03-20T18:08:45.000Z","size":95,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T08:14:12.975Z","etag":null,"topics":["helper","mock","mocking-methods","php","phpunit","runkit7","testing"],"latest_commit_sha":null,"homepage":"","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/QratorLabs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-19T12:56:22.000Z","updated_at":"2025-03-20T18:07:58.000Z","dependencies_parsed_at":"2024-02-19T17:51:47.185Z","dependency_job_id":"455af4a4-12e9-404b-bbe0-c6c575426275","html_url":"https://github.com/QratorLabs/Smocky","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"a54fe59d049a9ca01e0790a4afe7e9e50ecd2295"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QratorLabs%2FSmocky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QratorLabs%2FSmocky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QratorLabs%2FSmocky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QratorLabs%2FSmocky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QratorLabs","download_url":"https://codeload.github.com/QratorLabs/Smocky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249793857,"owners_count":21326619,"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":["helper","mock","mocking-methods","php","phpunit","runkit7","testing"],"created_at":"2024-11-16T21:06:31.090Z","updated_at":"2026-02-10T14:02:42.213Z","avatar_url":"https://github.com/QratorLabs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mock static methods\n\n...and a bit more ;)\n\n# Goals\n\n- easy mocking\n- make any changes revertible\n- revert changes automatically\n\n# Targets\n\nThere are several classes that will do the work:\n\n- For class methods:\n  - `MockedClassMethod` to mock any class with closure\n  - `UndefinedClassMethod` to make method disappear\n- For class constants:\n  - `MockedClassConstant`\n  - `UndefinedClassConstant`\n- For global constants:\n  - `MockedGlobalConstant`\n  - `UndefinedGlobalConstant`\n- For functions (global or Namespaced):\n  - `MockedFunction`\n  - `UndefinedFunction`\n\n# Install\n\n```shell\ncomposer require --dev qratorlabs/smocky\n```\n\n### Note\n\nThere is a workaround that ensures that any (defined) children of class, which method is mocking, have its own method,\ndefined by user or mocked (by Smocky - closure that calls parent).\n\nExample for code that will fail without this workaround following code will end up with `Segmentation fault: 11`\n\n```php\nclass Base\n{\n    public static function methodName()\n    {\n        return 'something';\n    }\n}\n\nclass Child extends Base\n{\n\n}\n\n// simulating PHPUnit test case\n(new class('test') extends \\PHPUnit\\Framework\\TestCase {\n\n    public function test(): void\n    {\n        // child should instanced (or loaded any other way)\n        $child = new Child();\n        // mocking method of base class\n        $method = new MockedClassMethod(Base::class, 'methodName');\n        // at least one call should be made\n        Base::methodName();\n    }\n})-\u003erun();\n```\n\n# Trivia\n\n## Revertible changes\n\nAll changes are made revertible by using internal storage and `__destruct` methods.\n\n## Drawbacks\n\nThing to keep in mind before using:\n\n- Mocking anything will hit memory consumption (ex. to preserve changes)\n- Mocking methods will hit performance (a bit)\n- To mock static class we must check (and mock) children of mocking class\n\n# Powered by\n\n- [runkit7](https://github.com/runkit7/runkit7)\n- [phpunit](https://github.com/sebastianbergmann/phpunit)\n\n# Tested with\n\n- [phpunit](https://github.com/sebastianbergmann/phpunit)\n- [phpstan](https://github.com/phpstan/phpstan)\n- [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqratorlabs%2Fsmocky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqratorlabs%2Fsmocky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqratorlabs%2Fsmocky/lists"}