Inheritance: extends Illuminate\Database\Eloquent\Model, use trait Mpociot\Teamwork\Traits\TeamworkTeamTrait
Esempio n. 1
0
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     if (empty($attributes['slug']) && !empty($attributes['name'])) {
         $attributes['slug'] = \Slugify::slugify($attributes['name']);
     }
 }
Esempio n. 2
0
 /**
  *
  */
 public function setUp()
 {
     parent::setUp();
     $this->artisan('migrate', ['--database' => 'testing', '--realpath' => realpath(__DIR__ . '/../src/database/migrations')]);
     $this->user = new User();
     $this->user->name = 'Marcel';
     $this->user->save();
     $this->team = TeamworkTeam::create(['name' => 'Test-Team']);
     $this->user->attachTeam($this->team);
 }
 public function setUp()
 {
     parent::setUp();
     $this->artisan('migrate', ['--database' => 'testing', '--realpath' => realpath(__DIR__ . '/../src/database/migrations')]);
     $this->user = new User();
     $this->user->name = 'Julia';
     $this->user->email = '*****@*****.**';
     $this->user->save();
     $this->inviter = new User();
     $this->inviter->name = 'Marcel';
     $this->inviter->email = '*****@*****.**';
     $this->inviter->save();
     $this->team = TeamworkTeam::create(['name' => 'Test-Team 2']);
     $this->invite = new TeamInvite();
     $this->invite->team_id = $this->team->getKey();
     $this->invite->user_id = $this->inviter->getKey();
     $this->invite->email = $this->user->email;
     $this->invite->type = 'invite';
     $this->invite->accept_token = md5(uniqid(microtime()));
     $this->invite->deny_token = md5(uniqid(microtime()));
     $this->invite->save();
 }
Esempio n. 4
0
 public function testUserCannotSwitchToNotExistingTeam()
 {
     $team1 = TeamworkTeam::create(['name' => 'Test-Team 1']);
     $team2 = TeamworkTeam::create(['name' => 'Test-Team 2']);
     $this->user->attachTeams([$team1, $team2]);
     $this->setExpectedException('Illuminate\\Database\\Eloquent\\ModelNotFoundException');
     $this->user->switchTeam(3);
 }
Esempio n. 5
0
 public function testInviteToTeamFiresEvent()
 {
     $team = TeamworkTeam::create(['name' => 'Test-Team 1']);
     $invite = $this->createInvite($team);
     $this->expectsEvents(\Mpociot\Teamwork\Events\UserInvitedToTeam::class);
 }