Created
January 17, 2013 22:24
-
-
Save JeffreyWay/4560401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class EloquentDogRepository implements DogRepository { | |
public function findBy($config) | |
{ | |
return Dog::where(function($query) use($config) { | |
foreach($config as $key => $value) { | |
$query->where($key, '=', $value); | |
} | |
})->get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I prefer to use the opposite direction. In my tests I'm using another fresh database. Yes, I spend time in clearing the database, but I'm as close as possible to the real situation. When the project/test is simple, it's nice to use mocks, but if you have some complex integration test, which perform dozen of things in the data is better to use a real database. If the database is completely new for the tests you still can run the tests independently/parallel and leave the original one.