public function testCanAcceptInvite() { /* |------------------------------------------------------------ | Set |------------------------------------------------------------ */ $team_id = 1; $app = m::mock('App'); $teamwork = new Teamwork($app); $app->auth = m::mock('Auth'); $user = m::mock('User'); $user->current_team_id = $team_id; $app->auth->shouldReceive('user')->andReturn($user); $teaminvite = m::mock('Mpociot\\Teamwork\\TeamInvite'); $teaminvite->shouldReceive('setAttribute')->andReturnSelf(); $teaminvite->shouldReceive('getAttribute')->andReturnSelf(); $teaminvite->team = "1"; $teaminvite->shouldReceive('delete')->once(); $user->shouldReceive('attachTeam')->with($teaminvite->team); $teamwork->acceptInvite($teaminvite); }
public function testHasPendingInviteTrue() { /* |------------------------------------------------------------ | Set |------------------------------------------------------------ */ $email = "*****@*****.**"; $team_id = 1; $app = m::mock('App'); $teamwork = new Teamwork($app); $token = "asd"; $teaminvite = m::mock('Mpociot\\Teamwork\\TeamInvite'); $app->shouldReceive('make')->with('Mpociot\\Teamwork\\TeamInvite')->once()->andReturn($teaminvite); /* |------------------------------------------------------------ | Expectation |------------------------------------------------------------ */ $teaminvite->shouldReceive('where')->once()->with('email', "=", $email)->andReturnSelf(); $teaminvite->shouldReceive('where')->once()->with('team_id', "=", $team_id)->andReturnSelf(); $teaminvite->shouldReceive('first')->once()->andReturnSelf(); $this->assertTrue($teamwork->hasPendingInvite($email, $team_id)); }
/** * * * @param \Mpociot\Teamwork\TeamInvite $invite * @static */ public static function denyInvite($invite) { return \Mpociot\Teamwork\Teamwork::denyInvite($invite); }