How can I unit test my Eloquent models when I'm using the ORM outside of Laravel? What I'm hoping to do it run tests on each model but somehow mock the database connection/query/builder(?) object.Below is something along the lines of what I'm trying to do:$capsule = new Capsule; $capsule->addConnection(array(    'driver'    => 'mysql',    'host'      => 'localhost',    'database'  => 'mydb',    'username'  => 'dbuser',    'password'  => 'badpass',    'charset'   => 'utf8',    'collation' => 'utf8_unicode_ci',    'prefix'    => ''));$capsule->bootEloquent();Below is my model:<?phpuse Illuminate\Database\Eloquent\Model as Eloquent;class Users extends Eloquent{    public function myCustomFind($id)    {        // .. lots of various checks before find() ...        return $this->find($id);    }}Then, in my unit tests I can do the following (not a working version, but I hope you can see what I'm hoping to do):$mockSomething->expects($this->once)    ->method('find')    ->with(1);$users = new Users();$users->setSomething($mockSomething);$user = $users->myCustomFind(1);...I just have no idea how to do this without full integration (data being written to the database). I just want to test my models, not the ORM, also so my tests are fast and only checking the correct params are passed to the query builder, and that my method handles the resulting data correctly. Will Eloquent allow this? I notice that Laravel has it's own TestCase class but from what I see this caters for all aspects of testing in Laravel (controllers, etc)If Eloquent is not a good choice for unit testing outside of Laravel, are there any popular ORMs that can? I haven't spent much time with others like Doctrine or Propel to know what they are capable of in that respect. Would appreciate any recommendations.
Unit testing Eloquent outside of Laravel
unit testing;orm;laravel;phpunit