public function testHasPendingInviteFromArray() { /* |------------------------------------------------------------ | Set |------------------------------------------------------------ */ $email = "*****@*****.**"; $team_id = 1; $app = m::mock('App'); $teamwork = new Teamwork($app); $team = ["id" => $team_id]; $token = "asd"; $inviteClass = 'Mpociot\\Teamwork\\TeamInvite'; Config::shouldReceive('get')->once()->with('teamwork.invite_model')->andReturn($inviteClass); $teaminvite = m::mock($inviteClass); $app->shouldReceive('make')->with($inviteClass)->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)); }
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)); }
/** * Checks if the given email address has a pending invite for the * provided Team * * @param $email * @param \Mpociot\Teamwork\Team|array|integer $team * @return bool * @static */ public static function hasPendingInvite($email, $team) { return \Mpociot\Teamwork\Teamwork::hasPendingInvite($email, $team); }