2FAuth/tests/Api/v1/Controllers/IconControllerTest.php

69 lines
1.3 KiB
PHP
Raw Normal View History

2021-11-14 01:52:46 +01:00
<?php
namespace Tests\Api\v1\Controllers;
use Illuminate\Http\UploadedFile;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\TestCase;
2021-11-22 01:09:54 +01:00
/**
* @covers \App\Api\v1\Controllers\IconController
*/
2021-11-14 01:52:46 +01:00
class IconControllerTest extends TestCase
{
use WithoutMiddleware;
/**
* @test
*/
public function test_upload_icon_returns_filename()
{
$file = UploadedFile::fake()->image('testIcon.jpg');
$response = $this->json('POST', '/api/v1/icons', [
'icon' => $file,
])
2021-11-14 01:52:46 +01:00
->assertCreated()
->assertJsonStructure([
'filename'
]);
}
/**
* @test
*/
public function test_upload_with_invalid_data_returns_validation_error()
{
$response = $this->json('POST', '/api/v1/icons', [
'icon' => null,
])
2021-11-14 01:52:46 +01:00
->assertStatus(422);
}
/**
* @test
*/
public function test_delete_icon_returns_success()
{
$response = $this->json('DELETE', '/api/v1/icons/testIcon.jpg')
->assertNoContent(204);
}
/**
* @test
*/
public function test_delete_invalid_icon_returns_success()
{
$response = $this->json('DELETE', '/api/v1/icons/null')
->assertNoContent(204);
}
}