snipe-it/tests/Feature/Groups/Ui/UpdateGroupTest.php
snipe 3de5f5882c Added/updated tests
Signed-off-by: snipe <snipe@snipe.net>
2025-02-11 01:07:41 +00:00

36 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature\Groups\Ui;
use App\Models\Group;
use App\Models\User;
use Tests\TestCase;
class UpdateGroupTest extends TestCase
{
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
->get(route('groups.edit', Group::factory()->create()->id))
->assertOk();
}
public function testUserCanEditGroups()
{
$group = Group::factory()->create(['name' => 'Test Group']);
$this->assertTrue(Group::where('name', 'Test Group')->exists());
$response = $this->actingAs(User::factory()->superuser()->create())
->put(route('groups.update', ['group' => $group]), [
'name' => 'Test Group Edited',
'notes' => 'Test Note Edited',
])
->assertStatus(302)
->assertSessionHasNoErrors()
->assertRedirect(route('groups.index'));
$this->followRedirects($response)->assertSee('Success');
$this->assertTrue(Group::where('name', 'Test Group Edited')->where('notes', 'Test Note Edited')->exists());
}
}