mirror of
https://github.com/koel/koel
synced 2024-12-24 03:23:06 +00:00
53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Integration\Services;
|
|
|
|
use function App\Helpers\album_cover_path;
|
|
use function App\Helpers\album_cover_url;
|
|
use App\Models\Album;
|
|
use App\Services\MediaMetadataService;
|
|
use Tests\TestCase;
|
|
|
|
class MediaMetadataServiceTest extends TestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->cleanUp();
|
|
}
|
|
|
|
public function testGetAlbumThumbnailUrl(): void
|
|
{
|
|
copy(__DIR__.'/../../blobs/cover.png', album_cover_path('album-cover-for-thumbnail-test.jpg'));
|
|
|
|
$album = Album::factory()->create(['cover' => 'album-cover-for-thumbnail-test.jpg']);
|
|
|
|
self::assertSame(
|
|
album_cover_url('album-cover-for-thumbnail-test_thumb.jpg'),
|
|
app(MediaMetadataService::class)->getAlbumThumbnailUrl($album)
|
|
);
|
|
|
|
self::assertFileExists(album_cover_path('album-cover-for-thumbnail-test_thumb.jpg'));
|
|
}
|
|
|
|
public function testGetAlbumThumbnailUrlWithNoCover(): void
|
|
{
|
|
$album = Album::factory()->create(['cover' => null]);
|
|
self::assertNull(app(MediaMetadataService::class)->getAlbumThumbnailUrl($album));
|
|
}
|
|
|
|
private function cleanUp(): void
|
|
{
|
|
@unlink(album_cover_path('album-cover-for-thumbnail-test.jpg'));
|
|
@unlink(album_cover_path('album-cover-for-thumbnail-test_thumb.jpg'));
|
|
self::assertFileDoesNotExist(album_cover_path('album-cover-for-thumbnail-test.jpg'));
|
|
self::assertFileDoesNotExist(album_cover_path('album-cover-for-thumbnail-test_thumb.jpg'));
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
$this->cleanUp();
|
|
parent::tearDown();
|
|
}
|
|
}
|