2023-03-07 15:31:24 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\MedialibraryHelper\Tests\Feature;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
use Zoomyboy\MedialibraryHelper\Tests\TestCase;
|
|
|
|
|
|
|
|
class MiddlewareTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
use RefreshDatabase;
|
|
|
|
|
|
|
|
public function testItReturns401WhenNotLoggedIn(): void
|
|
|
|
{
|
|
|
|
$this->registerModel();
|
|
|
|
$post = $this->newPost();
|
|
|
|
|
|
|
|
$response = $this->postJson('/mediaupload', [
|
|
|
|
'model' => 'post',
|
|
|
|
'id' => $post->id,
|
|
|
|
'collection' => 'defaultSingleFile',
|
|
|
|
'content' => base64_encode($this->pdfFile()->getContent()),
|
|
|
|
'name' => 'beispiel bild.jpg',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$response->assertStatus(401);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItReturns401WhenDestroying(): void
|
|
|
|
{
|
|
|
|
$this->registerModel();
|
|
|
|
$post = $this->newPost();
|
|
|
|
$media = $post->addMedia($this->pdfFile()->getPathname())->toMediaCollection('defaultSingleFile');
|
|
|
|
|
|
|
|
$response = $this->deleteJson("/mediaupload/{$media->id}");
|
|
|
|
|
|
|
|
$response->assertStatus(401);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function defineEnvironment($app)
|
|
|
|
{
|
2023-03-08 14:53:00 +01:00
|
|
|
$app['config']->set('media-library.middleware', ['web', 'auth:web']);
|
2023-03-07 15:31:24 +01:00
|
|
|
}
|
|
|
|
}
|