{"id":18907862,"url":"https://github.com/fkupper/private-sniffer-module","last_synced_at":"2026-03-06T01:30:26.835Z","repository":{"id":56992170,"uuid":"196403307","full_name":"fkupper/private-sniffer-module","owner":"fkupper","description":"Simple module that enables sniffing into private defined elements of an object while running unit tests with Codeception.","archived":false,"fork":false,"pushed_at":"2020-08-12T15:27:46.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T22:17:33.308Z","etag":null,"topics":["codeception-module","unit-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/fkupper.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":"2019-07-11T13:46:16.000Z","updated_at":"2020-10-03T18:09:53.000Z","dependencies_parsed_at":"2022-08-21T12:50:58.284Z","dependency_job_id":null,"html_url":"https://github.com/fkupper/private-sniffer-module","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkupper%2Fprivate-sniffer-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkupper%2Fprivate-sniffer-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkupper%2Fprivate-sniffer-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkupper%2Fprivate-sniffer-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkupper","download_url":"https://codeload.github.com/fkupper/private-sniffer-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239891433,"owners_count":19714141,"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":["codeception-module","unit-testing"],"created_at":"2024-11-08T09:23:40.805Z","updated_at":"2026-03-06T01:30:26.737Z","avatar_url":"https://github.com/fkupper.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Private Sniffer\n\n[![Total Downloads](https://poser.pugx.org/fkupper/private-sniffer-module/downloads)](//packagist.org/packages/fkupper/private-sniffer-module)\n[![Monthly Downloads](https://poser.pugx.org/fkupper/private-sniffer-module/d/monthly)](//packagist.org/packages/fkupper/private-sniffer-module)\n\nSimple Codeception module to check private elements of objects.\n\n# Installation\n\nCan be installed using composer:\n\n```\ncomposer require --dev fkupper/private-sniffer-module\n```\n # Usage\n\n Simple include the module on your unit suite config YML file:\n\n ``` yml\nmodules:\n    enabled: [PrivateSniffer]\n ```\n\n On your unit tests you can now inspect and test private attributes and methods:\n\n``` php\nclass Foo\n{\n    private $someInt = 1;\n\n    private sum(int $a, int $b): int\n    {\n        return $a + $b;\n    }\n}\n\nclass TestFoo extends \\Codeception\\Test\\Unit\n{\n    /**\n     * @var \\UnitTester\n     */\n    protected $tester;\n\n    // tests\n    public function testSum()\n    {\n        $foo = new Foo();\n\n        // get the value of the private attribute $someInt\n        $someInt = $this-\u003etester-\u003egetPrivatePropertyValue($foo, 'someInt');\n        $this-\u003eassertEquals(1, $someInt);\n\n        // get a closure of the private method sum\n        $sum = $this-\u003etester-\u003egetPrivateMethod($foo, 'sum');\n        $this-\u003eassertEquals(2 + 3, $sum(2, 3));\n    }\n}\n```\n# Is this a solution to test bad/not testable code?\n\nOf course not. This is meant to be used when critical and sentive part of your code must be tested and is not possible for any reason.\n\nBest practice still is to develop with unit testing in mind and refactor over time whatever you have that cannot be tested properly.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkupper%2Fprivate-sniffer-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkupper%2Fprivate-sniffer-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkupper%2Fprivate-sniffer-module/lists"}