public function testShouldConfirmUser() { // Make sure that the mock will return the table name $confide_user = m::mock(new _mockedUser()); $confide_user->shouldReceive('getTable')->andReturn('users')->once()->getMock()->shouldReceive('getKey')->andReturn('3')->once()->getMock()->shouldReceive('getKeyName')->andReturn('id')->once(); // Mocks DB in order to check for the following query: // DB::table('users')->where('id',3)->update(array('confirmed'=>1)); $database = m::mock('DatabaseManager'); $database->shouldReceive('connection')->andReturn($database)->once()->getMock()->shouldReceive('table')->with('users')->andReturn($database)->once()->getMock()->shouldReceive('where')->with('id', '3')->andReturn($database)->once()->getMock()->shouldReceive('update')->with(array('confirmed' => 1))->andReturn(0)->once(); $this->repo->app['db'] = $database; // Actually change the user password $this->assertTrue($this->repo->confirmUser($confide_user)); }
public function testShouldConfirmUser() { // Make sure that the mock will return an id $confide_user = m::mock(new _mockedUser()); $confide_user->_id = '123123'; // Make sure that the password reminders collection will receive a update $database = $this->repo->app['MongoLidConnector']; $database->users = $database; // The collection that should be accessed $database->shouldReceive('update')->with(array('_id' => '123123'), array('$set' => array('confirmed' => 1)))->andReturn(true)->once(); $this->repo->app['MongoLidConnector'] = $database; // Actually change the user password $this->assertTrue($this->repo->confirmUser($confide_user)); }