{"id":15284028,"url":"https://github.com/actuallyconnor/pseudo","last_synced_at":"2026-02-28T23:31:22.763Z","repository":{"id":257804068,"uuid":"863677824","full_name":"ActuallyConnor/pseudo","owner":"ActuallyConnor","description":"A system for mocking PHP PDO connections ","archived":false,"fork":false,"pushed_at":"2025-05-14T00:23:11.000Z","size":208,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T05:48:01.292Z","etag":null,"topics":["hacktoberfest","pdo","pdo-wrapper","php","phpunit"],"latest_commit_sha":null,"homepage":"https://pseudo-pdo.org","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/ActuallyConnor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-26T17:59:06.000Z","updated_at":"2025-05-14T00:23:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"428ac1a1-b5d2-4d3b-991d-209f9d7dbcb9","html_url":"https://github.com/ActuallyConnor/pseudo","commit_stats":null,"previous_names":["actuallyconnor/pseudo"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/ActuallyConnor/pseudo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActuallyConnor%2Fpseudo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActuallyConnor%2Fpseudo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActuallyConnor%2Fpseudo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActuallyConnor%2Fpseudo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ActuallyConnor","download_url":"https://codeload.github.com/ActuallyConnor/pseudo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActuallyConnor%2Fpseudo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263674465,"owners_count":23494578,"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":["hacktoberfest","pdo","pdo-wrapper","php","phpunit"],"created_at":"2024-09-30T14:48:44.522Z","updated_at":"2026-02-28T23:31:22.695Z","avatar_url":"https://github.com/ActuallyConnor.png","language":"PHP","readme":"# Pseudo\n\n## Introduction\n\nPseudo is a system for mocking PHP's PDO database connections. When writing unit tests for PHP applications, one\nfrequently has the need to test code that interacts with a database. However, in the true spirit of a unit test, the\ndatabase should be abstracted, as we can assume with some degree of certainty that things like network links to the\ndatabase server, the database connection drivers, and the database server and software itself are \"going to work\", and\nthey are outside the scope of our unit tests.\n\nEnter Pseudo. Pseudo allows you to have \"fake\" interactions with a database that produce predefined results every time.\nThis has 2 main advantages over actually interacting with a database. First, it saves having to write data fixtures in\nanother format, ensuring the data schema availability, loading the fixtures in, and then later cleaing and resetting\nthem between tests. Second, and somewhat as a result of the first, tests can run *significantly* faster because they are\nessentially talking to an in-memory object structure rather than incurring all the overhead of connecting and\ninteracting with an actual database.\n\nThe general idea is that Pseudo implements all the classes in the PDO system by inheriting from them and then\noverriding their methods. During your test, at the point where you would inject a PDO object into your data layer, you\ncan now inject a Pseudo\\Pdo object transparently, giving yourself 100% flexibility to control what your application now\n*thinks* is the database. In your unit test, you can express the mocks for your test in terms of SQL statements and\narrays of result data.\n\nFind the package on [packagist.org](https://packagist.org/packages/pseudo/pseudo)\n\n## Documentation\n\nhttps://pseudo-pdo.org\n\n### Documentation Generation\n\nThis project uses [readthedocs](https://readthedocs.io) and [mkdocs](https://mkdocs.org)\n\nTo load the local documentation page setup mkdocs locally and run:\n```shell\n$ mkdocs serve\n```\n\nYou can edit the `mkdocs.yaml` file to change the pages that show up in the sidebar.\n\nTo generate the docs, setup [phpDocumentor](https://phpdoc.org/) locally and then run:\n\n```shell\n$ phpdoc --directory=src --target=docs --template=\"vendor/saggre/phpdocumentor-markdown/themes/markdown\"\n```\n\n## Installation\n\n```\ncomposer require --dev pseudo/pseudo\n```\n\n### Usage\n\n#### Something you may want to test\n\n```php\n\u003c?php\nclass ObjectsModel {\n    public function __construct(private readonly PDO $pdo)\n    {\n    }\n    \n    public function getObjectsByFoo(string $foo): array\n    {\n        $statement = $this-\u003epdo-\u003eprepare('SELECT id FROM objects WHERE foo = :foo');\n\n        $statement-\u003eexecute(['foo' =\u003e 'bar']);\n        \n        $objects = $statement-\u003efetchAll();\n        \n        if (!$objects) {\n            throw new RuntimeException('Entity not found');\n        }\n        \n        return $objects;\n    }\n}\n```\n\n#### Tests with Pseudo\n\n```php\n\u003c?php\n\nclass ObjectsModelTest extends \\PHPUnit\\Framework\\TestCase {\n    public function testGetObjectsByFoo(): void {\n        $pdo = new Pseudo\\Pdo();\n\n        $objectsModel = new \\ObjectsModel($pdo);\n\n        $pdo-\u003emock(\n          \"SELECT id FROM objects WHERE foo = :foo'\", \n          ['foo' =\u003e 'bar'],\n          [['id' =\u003e 1, 'foo' =\u003e 'bar']]\n        );\n\n        $objects = $objectsModel-\u003egetObjectsByFoo('bar');\n        \n        $this-\u003eassertEquals([['id' =\u003e 1, 'foo' =\u003e 'bar']], $objects);\n    }\n}\n```\n\n### Supported features\n\nThe internal storage of mocks and results are associative arrays. Pseudo attempts to implement as much of the standard\nPDO feature set as possible, so varies different fetch modes, bindings, parameterized queries, etc. all work as you'd\nexpect them to.\n\n### Not implemented / wish-list items\n\n* The transaction api is implemented to the point of managing current transaction state, but transactions have no actual\n  effect\n* Anything related to scrolling cursors has not been implemented, and this includes the fetch modes that might require\n  them\n* Pseudo isn't strict-mode compatible, which means tests might fail due to unexpected errors with signatures and\n  offsets, etc. (I'd happily accept a pull request to fix this!)\n\n## Tests\n\nPseudo has a fairly robust test suite written with PHPUnit. If you'd like to run the tests, simply run\n`./vendor/bin/phpunit` in the root folder. The tests have no external library dependencies (other than phpunit) and\nshould require no additional setup or bootstrapping to run.\n\n## Requirements\n\nPseudo internals currently target PHP 8.1 and above. It has no external dependencies aside from the PDO extension,\nwhich seems rather obvious.\n\nPseudo is built and tested with error reporting set to ```E_ALL \u0026 ~(E_NOTICE | E_DEPRECATED | E_STRICT)```. If you are\nrunning in a stricter error reporting mode, your tests will most likely fail due to strict mode method signature\nviolations. (This is on the known issues / to do list)\n\n## Contributing\n\nWe are committed to a transparent development process and highly appreciate any contributions. Whether you are helping\nus fix bugs, proposing new features, improving our documentation or spreading the word - we would love to have you as a\npart of the community. Please refer to our contribution guidelines and code of conduct.\n\n- Bug Report: If you see an error message or encounter an issue while using Pseudo, please create a bug report.\n\n- Feature Request: If you have an idea or if there is a capability that is missing and would make development easier and\n  more robust, please submit a feature request.\n\n- Documentation Request: If you're reading the Pseudo docs and feel like you're missing something, please submit a\n  documentation request.\n\n## License\n\nThe Pseudo is open-sourced software licensed under the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factuallyconnor%2Fpseudo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factuallyconnor%2Fpseudo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factuallyconnor%2Fpseudo/lists"}