52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Screenshots;
|
|
|
|
use App\Models\Screenshot;
|
|
use App\Models\User;
|
|
use Tests\Facades\ScreenshotFactory;
|
|
use Tests\Facades\UserFactory;
|
|
use Tests\TestCase;
|
|
|
|
class RemoveTest extends TestCase
|
|
{
|
|
private const URI = '/screenshots/remove';
|
|
|
|
private User $admin;
|
|
|
|
private Screenshot $screenshot;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->admin = UserFactory::asAdmin()->withTokens()->create();
|
|
|
|
$this->screenshot = ScreenshotFactory::fake()->create();
|
|
}
|
|
|
|
public function test_remove(): void
|
|
{
|
|
$this->assertDatabaseHas('screenshots', $this->screenshot->toArray());
|
|
|
|
$response = $this->actingAs($this->admin)->postJson(self::URI, $this->screenshot->only('id'));
|
|
|
|
$response->assertOk();
|
|
$this->assertSoftDeleted('screenshots', $this->screenshot->only('id'));
|
|
}
|
|
|
|
public function test_unauthorized(): void
|
|
{
|
|
$response = $this->postJson(self::URI);
|
|
|
|
$response->assertUnauthorized();
|
|
}
|
|
|
|
public function test_without_params(): void
|
|
{
|
|
$response = $this->actingAs($this->admin)->postJson(self::URI);
|
|
|
|
$response->assertValidationError();
|
|
}
|
|
}
|