mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-28 06:59:41 -08:00
fb455be406
Signed-off-by: snipe <snipe@snipe.net>
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api\Users;
|
|
|
|
use App\Models\User;
|
|
use Tests\Support\InteractsWithSettings;
|
|
use Tests\TestCase;
|
|
use Tests\Support\InteractsWithAuthentication;
|
|
|
|
|
|
class UpdateUserApiTest extends TestCase
|
|
{
|
|
use InteractsWithSettings;
|
|
use InteractsWithAuthentication;
|
|
|
|
public function testApiUsersCanBeActivatedWithNumber()
|
|
{
|
|
$admin = User::factory()->superuser()->create();
|
|
$user = User::factory()->create(['activated' => 0]);
|
|
|
|
$this->actingAsForApi($admin)
|
|
->patch(route('api.users.update', $user), [
|
|
'activated' => 1,
|
|
]);
|
|
|
|
$this->assertEquals(1, $user->refresh()->activated);
|
|
}
|
|
|
|
public function testApiUsersCanBeActivatedWithBooleanTrue()
|
|
{
|
|
$admin = User::factory()->superuser()->create();
|
|
$user = User::factory()->create(['activated' => false]);
|
|
|
|
$this->actingAsForApi($admin)
|
|
->patch(route('api.users.update', $user), [
|
|
'activated' => true,
|
|
]);
|
|
|
|
$this->assertEquals(1, $user->refresh()->activated);
|
|
}
|
|
|
|
public function testApiUsersCanBeDeactivatedWithNumber()
|
|
{
|
|
$admin = User::factory()->superuser()->create();
|
|
$user = User::factory()->create(['activated' => true]);
|
|
|
|
$this->actingAsForApi($admin)
|
|
->patch(route('api.users.update', $user), [
|
|
'activated' => 0,
|
|
]);
|
|
|
|
$this->assertEquals(0, $user->refresh()->activated);
|
|
}
|
|
|
|
public function testApiUsersCanBeDeactivatedWithBooleanFalse()
|
|
{
|
|
$admin = User::factory()->superuser()->create();
|
|
$user = User::factory()->create(['activated' => true]);
|
|
|
|
$this->actingAsForApi($admin)
|
|
->patch(route('api.users.update', $user), [
|
|
'activated' => false,
|
|
]);
|
|
|
|
$this->assertEquals(0, $user->refresh()->activated);
|
|
}
|
|
|
|
}
|