medialibrary-helper/tests/Feature/IndexTest.php

30 lines
1.3 KiB
PHP

<?php
namespace Zoomyboy\MedialibraryHelper\Tests\Feature;
test('it gets all medias', function () {
$this->auth()->registerModel();
$post = $this->newPost();
$firstMedia = $post->addMedia($this->pdfFile()->getPathname())->withCustomProperties(['test' => 'old'])->preservingOriginal()->toMediaCollection('images');
$secondMedia = $post->addMedia($this->pdfFile()->getPathname())->withCustomProperties(['test' => 'old'])->preservingOriginal()->toMediaCollection('images');
$response = $this->getJson("/mediaupload/post/{$post->id}/images");
$response->assertStatus(200);
$response->assertJsonPath('0.id', $firstMedia->id);
$response->assertJsonPath('1.id', $secondMedia->id);
$response->assertJsonPath('1.properties.test', 'old');
});
test('it gets media for single', function () {
$this->auth()->registerModel();
$post = $this->newPost();
$media = $post->addMedia($this->pdfFile()->getPathname())->withCustomProperties(['test' => 'old'])->preservingOriginal()->toMediaCollection('defaultSingleFile');
$response = $this->getJson("/mediaupload/post/{$post->id}/defaultSingleFile");
$response->assertStatus(200);
$response->assertJsonPath('id', $media->id);
$response->assertJsonPath('properties.test', 'old');
});