{"id":21894771,"url":"https://github.com/zumba/mongounit","last_synced_at":"2025-09-08T09:37:20.353Z","repository":{"id":6297658,"uuid":"7532207","full_name":"zumba/mongounit","owner":"zumba","description":"PHPUnit extension that enables MongoDB data fixtures for test cases.","archived":false,"fork":false,"pushed_at":"2019-11-04T22:45:56.000Z","size":55,"stargazers_count":32,"open_issues_count":0,"forks_count":13,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-15T16:14:35.939Z","etag":null,"topics":["mongodb","php","phpunit-extension"],"latest_commit_sha":null,"homepage":"http://tech.zumba.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zumba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-10T01:16:24.000Z","updated_at":"2019-11-04T22:45:12.000Z","dependencies_parsed_at":"2022-08-22T20:41:05.693Z","dependency_job_id":null,"html_url":"https://github.com/zumba/mongounit","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zumba%2Fmongounit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zumba%2Fmongounit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zumba%2Fmongounit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zumba%2Fmongounit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zumba","download_url":"https://codeload.github.com/zumba/mongounit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249105471,"owners_count":21213535,"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":["mongodb","php","phpunit-extension"],"created_at":"2024-11-28T13:28:16.889Z","updated_at":"2025-04-15T16:14:41.256Z","avatar_url":"https://github.com/zumba.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mongounit is a PHPUnit extension for test cases that utilize MongoDB as their data source.\n\n[![Latest Stable Version](https://poser.pugx.org/zumba/mongounit/v/stable.png)](https://packagist.org/packages/zumba/mongounit)\n[![Build Status](https://secure.travis-ci.org/zumba/mongounit.png)](http://travis-ci.org/zumba/mongounit)\n\n## Requirements\n\n* PHP 5.6+\n* PHPUnit 4.0+\n* PECL mongodb 1.2+\n\n## Testing\n\n1. Install dependencies `composer install -dev`\n1. Run `./bin/phpunit`\n\n## Example use\n\n```php\n\u003c?php\n\nclass MyMongoTestCase extends \\PHPUnit_Framework_TestCase {\n\tuse \\Zumba\\PHPUnit\\Extensions\\Mongo\\TestTrait;\n\n\t/**\n\t * Get the mongo connection for this test.\n\t *\n\t * @return Zumba\\PHPUnit\\Extensions\\Mongo\\Client\\Connector\n\t */\n\tpublic function getMongoConnection() {\n\t\t// Add your credentials here\n\t\treturn new \\MongoDB\\Client();\n\t}\n\n\t/**\n\t * Get the dataset to be used for this test.\n\t *\n\t * @return Zumba\\PHPUnit\\Extensions\\Mongo\\DataSet\\DataSet\n\t */\n\tpublic function getMongoDataSet() {\n\t\t$dataset = new \\Zumba\\PHPUnit\\Extensions\\Mongo\\DataSet\\DataSet($this-\u003egetMongoConnection());\n\t\t$dataset-\u003esetFixture([\n\t\t\t'some_collection' =\u003e [\n\t\t\t\t['name' =\u003e 'Document 1'],\n\t\t\t\t['name' =\u003e 'Document 2']\n\t\t\t]\n\t\t]);\n\t\treturn $dataset;\n\t}\n\n\tpublic function testRead() {\n\t\t$result = $this-\u003egetMongoConnection()-\u003etest-\u003esome_collection-\u003efindOne(['name' =\u003e 'Document 2']);\n\t\t$this-\u003eassertEquals('Document 2', $result['name']);\n\t}\n\n}\n```\n\n[See full working example.](https://github.com/zumba/mongounit/blob/master/examples/PizzaTraitTest.php)\n\n## Note about PHP Versions\n\nPHP 5.5 and below are no longer actively supported. If you are using these version, stick with previous versions of mongounit, however it is recommended to stop using these versions of PHP.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzumba%2Fmongounit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzumba%2Fmongounit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzumba%2Fmongounit/lists"}