From ac238580349a4899a1f65114989dfef189c16e05 Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Tue, 29 Oct 2013 18:01:30 -0400 Subject: [PATCH] Added mongo test trait. Allows mongounit to be used with mixed database test cases (ie, it can't extend the mongounit testcase). 5.4+ only. --- .../PHPUnit/Extensions/Mongo/TestTrait.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php b/src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php new file mode 100644 index 0000000..48a95ff --- /dev/null +++ b/src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php @@ -0,0 +1,46 @@ +markTestSkipped('The Mongo extension is not available.'); + return; + } + $this->getMongoDataSet() + ->dropAllCollections() + ->buildCollections(); + } + + /** + * Cleanup after test. + * + * @return void + */ + public function tearDown() { + $this->getMongoDataSet()->dropAllCollections(); + } + + /** + * Retrieve a mongo connection client. + * + * @return Zumba\PHPUnit\Extensions\Mongo\Client\Connector + */ + protected abstract function getMongoConnection(); + + /** + * Retrieve a dataset object. + * + * @return Zumba\PHPUnit\Extensions\Mongo\DataSet\DataSet + */ + protected abstract function getMongoDataSet(); + +}