From 219c54411bb765bebd7813ad3e49ab05acf0b150 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 28 Jul 2019 17:14:42 +0200 Subject: Permissions: Added models and migrations --- tests/Unit/Models/TeamTest.php | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Unit/Models/TeamTest.php (limited to 'tests/Unit/Models/TeamTest.php') diff --git a/tests/Unit/Models/TeamTest.php b/tests/Unit/Models/TeamTest.php new file mode 100644 index 00000000..fdd5be44 --- /dev/null +++ b/tests/Unit/Models/TeamTest.php @@ -0,0 +1,71 @@ + 'Example team', + 'description' => 'Lorem Ipsum', + 'contact_name' => 'Con Tact', + 'contact_dect' => '1337', + 'contact_email' => 'foo@bar.batz', + 'restricted' => false, + 'self_signup' => true, + 'requires_drivers_license' => false, + 'show_on_frontend' => true, + 'show_on_dashboard' => true, + ]; + + /** + * @covers \Engelsystem\Models\Team::roles + */ + public function testRoles() + { + $role = $this->getRole(); + $role2 = $this->getRole([], ['name' => 'Another Role']); + + $team = new Team($this->data); + $team->save(); + $team->roles()->attach($role); + $team->roles()->attach($role2); + + $this->assertCount(2, $team->roles); + $this->assertEquals('Test Role', $team->roles()->get()->first()->name); + } + + /** + * @covers \Engelsystem\Models\Team::supporters + */ + public function testSupporters() + { + $user = $this->getUser(); + + $team = new Team($this->data); + $team->save(); + $team->supporters()->attach($user); + + $this->assertEquals('Test User', $team->supporters()->get()->first()->name); + } + + /** + * @covers \Engelsystem\Models\Team::users + */ + public function testUsers() + { + $user = $this->getUser(); + + $team = new Team($this->data); + $team->save(); + $team->users()->attach($user); + + $this->assertEquals('Test User', $team->users()->get()->first()->name); + } +} -- cgit v1.2.3-54-g00ecf