-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da3d772
commit 85631c3
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php namespace GeneaLabs\LaravelGovernor\Tests\Integration\Notifications; | ||
|
||
use GeneaLabs\LaravelGovernor\Permission; | ||
use GeneaLabs\LaravelGovernor\Team; | ||
use GeneaLabs\LaravelGovernor\TeamInvitation; | ||
use GeneaLabs\LaravelGovernor\Tests\Fixtures\User; | ||
use GeneaLabs\LaravelGovernor\Tests\UnitTestCase; | ||
|
||
class TeamTest extends UnitTestCase | ||
{ | ||
public function setUp() : void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->user = factory(User::class)->create(); | ||
$this->actingAs($this->user); | ||
$this->team = (new Team)->create([ | ||
"name" => "Test Team", | ||
"description" => "bla bla bla", | ||
]); | ||
$this->user->teams()->attach($this->team); | ||
$this->team->load("members"); | ||
} | ||
|
||
public function testMembersRelationship() | ||
{ | ||
$this->assertTrue($this->team->members->contains($this->user)); | ||
} | ||
|
||
public function testOwnedByRelationship() | ||
{ | ||
$this->assertEquals($this->team->ownedBy->toArray(), $this->user->toArray()); | ||
} | ||
|
||
public function testInvitationsRelationship() | ||
{ | ||
$invitation = (new TeamInvitation)->create([ | ||
"team_id" => $this->team->id, | ||
"email" => "test1@example.com", | ||
]); | ||
|
||
$this->assertTrue($this->team->invitations->contains($invitation)); | ||
} | ||
|
||
public function testPermissionsRelationship() | ||
{ | ||
$permission = (new Permission)->firstOrCreate([ | ||
"team_id" => $this->team->id, | ||
"entity_name" => "author", | ||
"action_name" => "create", | ||
"ownership_name" => "any", | ||
]); | ||
|
||
$this->assertTrue($this->team->permissions->contains($permission)); | ||
} | ||
} |
Binary file not shown.