-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1176 from HDInnovations/development
(Tests) Staff Controllers
- Loading branch information
Showing
6 changed files
with
261 additions
and
186 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
tests/Feature/Http/Controllers/Staff/CheaterControllerTest.php
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,48 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Http\Controllers\Staff; | ||
|
||
use App\Models\Group; | ||
use App\Models\User; | ||
use GroupsTableSeeder; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @see \App\Http\Controllers\Staff\CheaterController | ||
*/ | ||
class CheaterControllerTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
protected function createStaffUser() | ||
{ | ||
return factory(User::class)->create([ | ||
'group_id' => function () { | ||
return factory(Group::class)->create([ | ||
'is_owner' => true, | ||
'is_admin' => true, | ||
'is_modo' => true, | ||
])->id; | ||
}, | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function index_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
|
||
$response = $this->actingAs($user)->get(route('staff.cheaters.index')); | ||
|
||
$response->assertOk(); | ||
$response->assertViewIs('Staff.cheater.index'); | ||
$response->assertViewHas('cheaters'); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/Feature/Http/Controllers/Staff/GiftControllerTest.php
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,67 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Http\Controllers\Staff; | ||
|
||
use App\Models\Group; | ||
use App\Models\User; | ||
use GroupsTableSeeder; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @see \App\Http\Controllers\Staff\GiftController | ||
*/ | ||
class GiftControllerTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
protected function createStaffUser() | ||
{ | ||
return factory(User::class)->create([ | ||
'group_id' => function () { | ||
return factory(Group::class)->create([ | ||
'is_owner' => true, | ||
'is_admin' => true, | ||
'is_modo' => true, | ||
])->id; | ||
}, | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function index_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
|
||
$response = $this->actingAs($user)->get(route('staff.gifts.index')); | ||
|
||
$response->assertOk(); | ||
$response->assertViewIs('Staff.gift.index'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function store_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$staff = $this->createStaffUser(); | ||
$user = factory(User::class)->create(); | ||
|
||
$response = $this->actingAs($staff)->post(route('staff.gifts.store'), [ | ||
'username' => $user->username, | ||
'seedbonus' => '100', | ||
'invites' => '100', | ||
'fl_tokens' => '100', | ||
]); | ||
|
||
$response->assertRedirect(route('staff.gifts.index')); | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
tests/Feature/Http/Controllers/Staff/GroupControllerTest.php
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,146 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Http\Controllers\Staff; | ||
|
||
use App\Models\Group; | ||
use App\Models\User; | ||
use GroupsTableSeeder; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @see \App\Http\Controllers\Staff\GroupController | ||
*/ | ||
class GroupControllerTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
protected function createStaffUser() | ||
{ | ||
return factory(User::class)->create([ | ||
'group_id' => function () { | ||
return factory(Group::class)->create([ | ||
'is_owner' => true, | ||
'is_admin' => true, | ||
'is_modo' => true, | ||
])->id; | ||
}, | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function create_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
|
||
$response = $this->actingAs($user)->get(route('staff.groups.create')); | ||
|
||
$response->assertOk(); | ||
$response->assertViewIs('Staff.group.create'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function edit_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
$group = factory(Group::class)->create(); | ||
|
||
$response = $this->actingAs($user)->get(route('staff.groups.edit', ['id' => $group->id])); | ||
|
||
$response->assertOk(); | ||
$response->assertViewIs('Staff.group.edit'); | ||
$response->assertViewHas('group'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function index_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
|
||
$response = $this->actingAs($user)->get(route('staff.groups.index')); | ||
|
||
$response->assertOk(); | ||
$response->assertViewIs('Staff.group.index'); | ||
$response->assertViewHas('groups'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function store_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
$group = factory(Group::class)->make(); | ||
|
||
$response = $this->actingAs($user)->post(route('staff.groups.store'), [ | ||
'name' => $group->name, | ||
'slug' => $group->slug, | ||
'position' => $group->position, | ||
'level' => $group->level, | ||
'color' => $group->color, | ||
'icon' => $group->icon, | ||
'effect' => $group->effect, | ||
'is_internal' => $group->is_internal, | ||
'is_owner' => $group->is_owner, | ||
'is_admin' => $group->is_admin, | ||
'is_modo' => $group->is_modo, | ||
'is_trusted' => $group->is_trusted, | ||
'is_immune' => $group->is_immune, | ||
'is_freeleech' => $group->is_freeleech, | ||
'can_upload' => $group->can_upload, | ||
'is_incognito' => $group->is_incognito, | ||
'autogroup' => $group->autogroup, | ||
]); | ||
|
||
$response->assertRedirect(route('staff.groups.index')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function update_returns_an_ok_response() | ||
{ | ||
$this->seed(GroupsTableSeeder::class); | ||
|
||
$user = $this->createStaffUser(); | ||
$group = factory(Group::class)->create(); | ||
|
||
$response = $this->actingAs($user)->post(route('staff.groups.update', ['id' => $group->id]), [ | ||
'name' => $group->name, | ||
'slug' => $group->slug, | ||
'position' => $group->position, | ||
'level' => $group->level, | ||
'color' => $group->color, | ||
'icon' => $group->icon, | ||
'effect' => $group->effect, | ||
'is_internal' => $group->is_internal, | ||
'is_owner' => $group->is_owner, | ||
'is_admin' => $group->is_admin, | ||
'is_modo' => $group->is_modo, | ||
'is_trusted' => $group->is_trusted, | ||
'is_immune' => $group->is_immune, | ||
'is_freeleech' => $group->is_freeleech, | ||
'can_upload' => $group->can_upload, | ||
'is_incognito' => $group->is_incognito, | ||
'autogroup' => $group->autogroup, | ||
]); | ||
|
||
$response->assertRedirect(route('staff.groups.index')); | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
tests/Todo/Feature/Http/Controllers/Staff/CheaterControllerTest.php
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
tests/Todo/Feature/Http/Controllers/Staff/GiftControllerTest.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.