Shuffled tests around again

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-06-12 12:12:15 +01:00
parent 67ab2536bc
commit 134183ef16
4 changed files with 34 additions and 49 deletions

View file

@ -11,7 +11,7 @@ use Tests\TestCase;
class ViewUserTest extends TestCase
{
public function testCanReturnUser()
public function testCanReturnUser()
{
$user = User::factory()->create();

View file

@ -1,45 +0,0 @@
<?php
namespace Tests\Feature\Users;
use Illuminate\Support\Facades\Notification;
use App\Models\Company;
use App\Models\User;
use Tests\TestCase;
use App\Notifications\CurrentInventory;
class DeleteUserTest extends TestCase
{
public function testPermissionsToDeleteUser()
{
$this->settings->enableMultipleFullCompanySupport();
[$companyA, $companyB] = Company::factory()->count(2)->create();
$superuser = User::factory()->superuser()->create();
$userFromA = User::factory()->for($companyA)->create();
$userFromB = User::factory()->for($companyB)->create();
$this->followingRedirects()->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
->delete(route('users.destroy', ['user' => $userFromB->id]))
->assertStatus(403);
$this->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
->delete(route('users.destroy', ['user' => $userFromA->id]))
->assertStatus(302)
->assertRedirect(route('users.index'));
$this->actingAs($superuser)
->post(route('users.email', ['userId' => $userFromA->id]))
->assertStatus(302);
$this->actingAs($superuser)
->post(route('users.email', ['userId' => $userFromB->id]))
->assertStatus(302);
}
}

View file

@ -13,7 +13,37 @@ use App\Models\Asset;
class DeleteUserTest extends TestCase
{
public function testPermissionsToDeleteUser()
{
$this->settings->enableMultipleFullCompanySupport();
[$companyA, $companyB] = Company::factory()->count(2)->create();
$superuser = User::factory()->superuser()->create();
$userFromA = User::factory()->for($companyA)->create();
$userFromB = User::factory()->for($companyB)->create();
$this->followingRedirects()->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
->delete(route('users.destroy', ['user' => $userFromB->id]))
->assertStatus(403);
$this->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
->delete(route('users.destroy', ['user' => $userFromA->id]))
->assertStatus(302)
->assertRedirect(route('users.index'));
$this->actingAs($superuser)
->post(route('users.email', ['userId' => $userFromA->id]))
->assertStatus(302);
$this->actingAs($superuser)
->post(route('users.email', ['userId' => $userFromB->id]))
->assertStatus(302);
}
public function testDisallowUserDeletionIfStillManagingPeople()
{
$manager = User::factory()->create();

View file

@ -1,12 +1,12 @@
<?php
namespace Tests\Feature\Users;
namespace Feature\Users\Ui;
use Illuminate\Support\Facades\Notification;
use App\Models\Company;
use App\Models\User;
use Tests\TestCase;
use App\Notifications\CurrentInventory;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class ViewUserTest extends TestCase
{