A free open source IT asset/license management system
Organize existing tests
Marcus Mooredb81209fe149
diff --git a/tests/Feature/Users/Ui/EmailAssignedToUserTest.php b/tests/Feature/Users/Ui/EmailAssignedToUserTest.phpnew file mode 100644index 0000000000..4f2250d84a--- /dev/null+++ b/tests/Feature/Users/Ui/EmailAssignedToUserTest.php@@ -0,0 +1,41 @@+<?php++namespace Tests\Feature\Users\Ui;++use App\Models\Company;+use App\Models\User;+use App\Notifications\CurrentInventory;+use Illuminate\Support\Facades\Notification;+use Tests\TestCase;++class EmailAssignedToUserTest extends TestCase+{+ public function testUserWithoutCompanyPermissionsCannotSendInventory()+ {++ Notification::fake();++ $this->settings->enableMultipleFullCompanySupport();++ [$companyA, $companyB] = Company::factory()->count(2)->create();++ $superuser = User::factory()->superuser()->create();+ $user = User::factory()->for($companyB)->create();++ $this->actingAs(User::factory()->viewUsers()->for($companyA)->create())+ ->post(route('users.email', ['userId' => $user->id]))+ ->assertStatus(403);++ $this->actingAs(User::factory()->viewUsers()->for($companyB)->create())+ ->post(route('users.email', ['userId' => $user->id]))+ ->assertStatus(302);++ $this->actingAs($superuser)+ ->post(route('users.email', ['userId' => $user->id]))+ ->assertStatus(302);++ Notification::assertSentTo(+ [$user], CurrentInventory::class+ );+ }+}diff --git a/tests/Feature/Users/Ui/PrintUserTest.php b/tests/Feature/Users/Ui/PrintUserTest.phpnew file mode 100644index 0000000000..3e389232fb--- /dev/null+++ b/tests/Feature/Users/Ui/PrintUserTest.php@@ -0,0 +1,33 @@+<?php++namespace Tests\Feature\Users\Ui;++use App\Models\Company;+use App\Models\User;+use Tests\TestCase;++class PrintUserTest extends TestCase+{+ public function testPermissionsForPrintAllInventoryPage()+ {+ $this->settings->enableMultipleFullCompanySupport();++ [$companyA, $companyB] = Company::factory()->count(2)->create();++ $superuser = User::factory()->superuser()->create();+ $user = User::factory()->for($companyB)->create();++ $this->actingAs(User::factory()->viewUsers()->for($companyA)->create())+ ->get(route('users.print', ['userId' => $user->id]))+ ->assertStatus(302);++ $this->actingAs(User::factory()->viewUsers()->for($companyB)->create())+ ->get(route('users.print', ['userId' => $user->id]))+ ->assertStatus(200);++ $this->actingAs($superuser)+ ->get(route('users.print', ['userId' => $user->id]))+ ->assertOk()+ ->assertStatus(200);+ }+}diff --git a/tests/Feature/Users/Ui/ViewUserTest.php b/tests/Feature/Users/Ui/ViewUserTest.phpindex cb21a1e9e2..dd452d06e5 100644--- a/tests/Feature/Users/Ui/ViewUserTest.php+++ b/tests/Feature/Users/Ui/ViewUserTest.php@@ -4,8 +4,6 @@ namespace Tests\Feature\Users\Ui;use App\Models\Company;use App\Models\User;-use App\Notifications\CurrentInventory;-use Illuminate\Support\Facades\Notification;use Tests\TestCase;class ViewUserTest extends TestCase@@ -28,56 +26,4 @@ class ViewUserTest extends TestCase->assertOk()->assertStatus(200);}-- public function testPermissionsForPrintAllInventoryPage()- {- $this->settings->enableMultipleFullCompanySupport();-- [$companyA, $companyB] = Company::factory()->count(2)->create();-- $superuser = User::factory()->superuser()->create();- $user = User::factory()->for($companyB)->create();-- $this->actingAs(User::factory()->viewUsers()->for($companyA)->create())- ->get(route('users.print', ['userId' => $user->id]))- ->assertStatus(302);-- $this->actingAs(User::factory()->viewUsers()->for($companyB)->create())- ->get(route('users.print', ['userId' => $user->id]))- ->assertStatus(200);-- $this->actingAs($superuser)- ->get(route('users.print', ['userId' => $user->id]))- ->assertOk()- ->assertStatus(200);- }-- public function testUserWithoutCompanyPermissionsCannotSendInventory()- {-- Notification::fake();-- $this->settings->enableMultipleFullCompanySupport();-- [$companyA, $companyB] = Company::factory()->count(2)->create();-- $superuser = User::factory()->superuser()->create();- $user = User::factory()->for($companyB)->create();-- $this->actingAs(User::factory()->viewUsers()->for($companyA)->create())- ->post(route('users.email', ['userId' => $user->id]))- ->assertStatus(403);-- $this->actingAs(User::factory()->viewUsers()->for($companyB)->create())- ->post(route('users.email', ['userId' => $user->id]))- ->assertStatus(302);-- $this->actingAs($superuser)- ->post(route('users.email', ['userId' => $user->id]))- ->assertStatus(302);-- Notification::assertSentTo(- [$user], CurrentInventory::class- );- }}