mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-16 10:34:08 -08:00
0a7e053985
Signed-off-by: snipe <snipe@snipe.net>
38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Departments\Ui;
|
|
|
|
use App\Models\Department;
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use Tests\TestCase;
|
|
|
|
class CreateDepartmentsTest extends TestCase
|
|
{
|
|
public function testPermissionRequiredToCreateDepartment()
|
|
{
|
|
$this->actingAs(User::factory()->create())
|
|
->post(route('departments.store'), [
|
|
'name' => 'Test Department',
|
|
'company_id' => Company::factory()->create()->id
|
|
])
|
|
->assertForbidden();
|
|
}
|
|
|
|
public function testUserCanCreateDepartments()
|
|
{
|
|
$this->assertFalse(Department::where('name', 'Test Department')->exists());
|
|
|
|
$this->actingAs(User::factory()->superuser()->create())
|
|
->post(route('departments.store'), [
|
|
'name' => 'Test Department',
|
|
'company_id' => Company::factory()->create()->id
|
|
])
|
|
->assertRedirect(route('departments.index'));
|
|
|
|
$this->assertTrue(Department::where('name', 'Test Department')->exists());
|
|
}
|
|
|
|
|
|
}
|