public function testUserExists()
 {
     // Make sure that the mock will return the table name
     $confide_user = m::mock(new _mockedUser());
     $confide_user->username = '******';
     $confide_user->email = '*****@*****.**';
     $confide_user->shouldReceive('getTable')->andReturn('users')->once();
     // Mocks DB in order to check for the following query:
     //     DB::table('users')->where('email', '*****@*****.**')->orWhere('username', 'bob')->count();
     $database = m::mock('DatabaseManager');
     $database->shouldReceive('connection')->andReturn($database)->once()->getMock()->shouldReceive('table')->with('users')->andReturn($database)->once()->getMock()->shouldReceive('where')->with('email', '*****@*****.**')->andReturn($database)->once()->getMock()->shouldReceive('orWhere')->with('username', 'Bob')->andReturn($database)->once()->getMock()->shouldReceive('count')->andReturn(1)->once();
     $this->repo->app['db'] = $database;
     // Actually checks if the user exists
     $this->assertEquals(1, $this->repo->userExists($confide_user));
 }
 public function testUserExists()
 {
     // Make sure that the mock will have it's attributes
     $confide_user = m::mock(new _mockedUser());
     $confide_user->username = '******';
     $confide_user->email = '*****@*****.**';
     // The query should be
     $query = array('$or' => array(array('username' => $confide_user->username), array('email' => $confide_user->email)));
     // Make sure that the password reminders collection will receive a find and count
     $database = $this->repo->app['MongoLidConnector'];
     $database->users = $database;
     // The collection that should be accessed
     $database->shouldReceive('find')->with($query)->andReturn($database)->once()->getMock()->shouldReceive('count')->andReturn(1)->once();
     $this->repo->app['MongoLidConnector'] = $database;
     // Actually checks if the user exists
     $this->assertEquals(1, $this->repo->userExists($confide_user));
 }