News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Zumba Engineering Blog:
Incorporating Mongounit into Multi-datasource Models with Traits
October 31, 2013 @ 10:42:27

On the Zubma Engineering blog today Chris Saylor has written up a tutorial showing how they used traits to use multiple data sources with Mongounit, working around the single source limitations it enforces.

A while back we open sourced Mongounit, a PHPUnit extension for testing models utilizing mongodb. One key issue that we've discovered as we incorporate MongoDB into more of our data models is that extending Mongounit's TestCase class limits that unit test towards Mongo only as the datasource. Since only a portion of our data is in Mongo while the remaining is in MySQL, limiting a test case to work with one datasource or another is too limiting.

They tried two other solutions first, separating out the tests by data source and manually clear the Mongo data in the tests, but both ran into problems. Instead, they opted to use traits to provide drop-in Mongo testing support as needed. It provides a simple interface to set up and tear down the needed Mongo resources - an example of which is also provided in the post. The code for the trait can be found on Github.

0 comments voice your opinion now!
trait mongounit unittest database multiple source model

Link: http://engineering.zumba.com/2013/10/30/multiple-data-sources-phpunit-testing/

blog comments powered by Disqus

Similar Posts

Greg Beaver\'s Blog: Protecting a MySQL user/password in a PHP script

NetTuts.com: Learn to Create Interactive Drill-Down Dashboards with PHP and FusionCharts

Tim Koschuetzki's Blog: How to put Combined Fields Into CakePHP's Model->generateList()

Anna Filina's Blog: 10 Reasons to Write Unit Tests

PHPMaster.com: Rockmongo for PHP-Powered MongoDB Administration


Community Events











Don't see your event here?
Let us know!


introduction symfony2 opinion package application security example unittest release overview framework composer facebook code component hack hhvm podcast install language

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework