koel/tests/Integration/Services/FileSynchronizerTest.php

58 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Integration\Services;
use App\Services\FileSynchronizer;
use Tests\TestCase;
class FileSynchronizerTest extends TestCase
{
2021-06-05 10:47:56 +00:00
private FileSynchronizer $fileSynchronizer;
2019-07-22 07:03:23 +00:00
public function setUp(): void
{
parent::setUp();
$this->fileSynchronizer = app(FileSynchronizer::class);
}
2019-07-22 07:03:23 +00:00
public function testGetFileInfo(): void
{
2020-12-22 20:11:22 +00:00
$info = $this->fileSynchronizer->setFile(__DIR__ . '/../../songs/full.mp3')->getFileInfo();
$expectedData = [
'artist' => 'Koel',
'album' => 'Koel Testing Vol. 1',
'compilation' => false,
'title' => 'Amet',
'track' => 5,
'disc' => 3,
'lyrics' => "Foo\rbar",
'cover' => [
2020-12-22 20:11:22 +00:00
'data' => file_get_contents(__DIR__ . '/../../blobs/cover.png'),
'image_mime' => 'image/png',
'image_width' => 512,
'image_height' => 512,
'imagetype' => 'PNG',
'picturetype' => 'Other',
'description' => '',
'datalength' => 7627,
],
2020-12-22 20:11:22 +00:00
'path' => __DIR__ . '/../../songs/full.mp3',
'mtime' => filemtime(__DIR__ . '/../../songs/full.mp3'),
'albumartist' => '',
];
self::assertArraySubset($expectedData, $info);
2020-09-06 18:21:39 +00:00
self::assertEqualsWithDelta(10.083, $info['length'], 0.001);
}
/** @test */
public function testSongWithoutTitleHasFileNameAsTitle(): void
{
2020-12-22 20:11:22 +00:00
$this->fileSynchronizer->setFile(__DIR__ . '/../../songs/blank.mp3');
self::assertSame('blank', $this->fileSynchronizer->getFileInfo()['title']);
}
}