Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Created January 17, 2013 22:24
Show Gist options
  • Save JeffreyWay/4560401 to your computer and use it in GitHub Desktop.
Save JeffreyWay/4560401 to your computer and use it in GitHub Desktop.
<?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();
}
}
@krasimir
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment