Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zumba/mongounit
PHPUnit extension that enables MongoDB data fixtures for test cases.
https://github.com/zumba/mongounit
mongodb php phpunit-extension
Last synced: about 1 month ago
JSON representation
PHPUnit extension that enables MongoDB data fixtures for test cases.
- Host: GitHub
- URL: https://github.com/zumba/mongounit
- Owner: zumba
- License: other
- Created: 2013-01-10T01:16:24.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2019-11-04T22:45:56.000Z (about 5 years ago)
- Last Synced: 2024-08-10T09:05:50.169Z (5 months ago)
- Topics: mongodb, php, phpunit-extension
- Language: PHP
- Homepage: http://tech.zumba.com
- Size: 53.7 KB
- Stars: 32
- Watchers: 11
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
Mongounit is a PHPUnit extension for test cases that utilize MongoDB as their data source.
[![Latest Stable Version](https://poser.pugx.org/zumba/mongounit/v/stable.png)](https://packagist.org/packages/zumba/mongounit)
[![Build Status](https://secure.travis-ci.org/zumba/mongounit.png)](http://travis-ci.org/zumba/mongounit)## Requirements
* PHP 5.6+
* PHPUnit 4.0+
* PECL mongodb 1.2+## Testing
1. Install dependencies `composer install -dev`
1. Run `./bin/phpunit`## Example use
```php
getMongoConnection());
$dataset->setFixture([
'some_collection' => [
['name' => 'Document 1'],
['name' => 'Document 2']
]
]);
return $dataset;
}public function testRead() {
$result = $this->getMongoConnection()->test->some_collection->findOne(['name' => 'Document 2']);
$this->assertEquals('Document 2', $result['name']);
}}
```[See full working example.](https://github.com/zumba/mongounit/blob/master/examples/PizzaTraitTest.php)
## Note about PHP Versions
PHP 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.