mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
fix: static analysis errors
This commit is contained in:
parent
8eb86d01a8
commit
66badd0098
15 changed files with 35 additions and 6 deletions
|
@ -15,7 +15,7 @@ class AlbumFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'artist_id' => Artist::factory(),
|
||||
'name' => ucwords($this->faker->words(random_int(2, 5), true)),
|
||||
'name' => $this->faker->colorName,
|
||||
'cover' => md5(uniqid()) . '.jpg',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class SongFactory extends Factory
|
|||
return [
|
||||
'album_id' => $album->id,
|
||||
'artist_id' => $album->artist->id,
|
||||
'title' => ucwords($this->faker->words(random_int(2, 5), true)),
|
||||
'title' => $this->faker->sentence,
|
||||
'length' => $this->faker->randomFloat(2, 10, 500),
|
||||
'track' => random_int(1, 20),
|
||||
'lyrics' => $this->faker->paragraph(),
|
||||
|
|
|
@ -25,6 +25,7 @@ parameters:
|
|||
- '#should return App\\Models\\.*(\|null)? but returns Illuminate\\Database\\Eloquent\\Model(\|null)?#'
|
||||
# Laravel factories allow declaration of dynamic methods as "states"
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Factories\\Factory::#'
|
||||
- '#expects App\\Models\\User\|null, Illuminate\\Database\\Eloquent\\Collection\|Illuminate\\Database\\Eloquent\\Model given#'
|
||||
|
||||
excludePaths:
|
||||
- ./routes/console.php
|
||||
|
|
|
@ -20,8 +20,11 @@ class InteractionTest extends TestCase
|
|||
public function testIncreasePlayCount(): void
|
||||
{
|
||||
$this->withoutEvents();
|
||||
|
||||
/** @var User $user */
|
||||
$user = User::factory()->create();
|
||||
|
||||
/** @var Song $song */
|
||||
$song = Song::orderBy('id')->first();
|
||||
$this->postAsUser('api/interaction/play', ['song' => $song->id], $user);
|
||||
|
||||
|
@ -45,8 +48,10 @@ class InteractionTest extends TestCase
|
|||
{
|
||||
$this->expectsEvents(SongLikeToggled::class);
|
||||
|
||||
/** @var User $user */
|
||||
$user = User::factory()->create();
|
||||
|
||||
/** @var Song $song */
|
||||
$song = Song::orderBy('id')->first();
|
||||
$this->postAsUser('api/interaction/like', ['song' => $song->id], $user);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ class ProfileTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
$this->user = User::factory()->create(['password' => Hash::make('secret')]);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ abstract class TestCase extends BaseTestCase
|
|||
{
|
||||
private function jsonAsUser(?User $user, string $method, $uri, array $data = [], array $headers = []): TestResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $user ?: User::factory()->create();
|
||||
$headers['X-Requested-With'] = 'XMLHttpRequest';
|
||||
$headers['Authorization'] = 'Bearer ' . $user->createToken('koel')->plainTextToken;
|
||||
|
|
|
@ -57,6 +57,7 @@ class StreamerFactoryTest extends TestCase
|
|||
/** @var StreamerFactory $streamerFactory */
|
||||
$streamerFactory = app(StreamerFactory::class);
|
||||
|
||||
/** @var Song $song */
|
||||
$song = Song::factory()->make();
|
||||
self::assertInstanceOf(TranscodingStreamer::class, $streamerFactory->createStreamer($song, true));
|
||||
}
|
||||
|
@ -88,6 +89,7 @@ class StreamerFactoryTest extends TestCase
|
|||
/** @var StreamerFactory $streamerFactory */
|
||||
$streamerFactory = app(StreamerFactory::class);
|
||||
|
||||
/** @var Song $song */
|
||||
$song = Song::factory()->make();
|
||||
self::assertInstanceOf($expectedClass, $streamerFactory->createStreamer($song));
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class DownloadAlbumCoverTest extends TestCase
|
|||
|
||||
public function testHandle(): void
|
||||
{
|
||||
/** @var Album $album */
|
||||
$album = Album::factory()->make(['cover' => null]);
|
||||
$event = new AlbumInformationFetched($album, ['image' => 'https://foo.bar/baz.jpg']);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class DownloadArtistImageTest extends TestCase
|
|||
|
||||
public function testHandle(): void
|
||||
{
|
||||
/** @var Artist $artist */
|
||||
$artist = Artist::factory()->make(['image' => null]);
|
||||
$event = new ArtistInformationFetched($artist, ['image' => 'https://foo.bar/baz.jpg']);
|
||||
|
||||
|
|
|
@ -43,11 +43,21 @@ class AlbumTest extends TestCase
|
|||
/** @dataProvider provideEmptyAlbumNames */
|
||||
public function testNewAlbumWithoutNameIsCreatedAsUnknownAlbum($name): void
|
||||
{
|
||||
self::assertEquals('Unknown Album', Album::getOrCreate(Artist::factory()->create(), $name)->name);
|
||||
/** @var Artist $artist */
|
||||
$artist = Artist::factory()->create();
|
||||
|
||||
$album = Album::getOrCreate($artist, $name);
|
||||
|
||||
self::assertEquals('Unknown Album', $album->name);
|
||||
}
|
||||
|
||||
public function testNewAlbumIsCreatedWithArtistAsVariousIfIsCompilationFlagIsTrue(): void
|
||||
{
|
||||
self::assertTrue(Album::getOrCreate(Artist::factory()->create(), 'Foo', true)->artist->is_various);
|
||||
/** @var Artist $artist */
|
||||
$artist = Artist::factory()->create();
|
||||
|
||||
$album = Album::getOrCreate($artist, 'Foo', true);
|
||||
|
||||
self::assertTrue($album->artist->is_various);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ class SongZipArchiveTest extends TestCase
|
|||
{
|
||||
public function testAddSongIntoArchive(): void
|
||||
{
|
||||
/** @var Song $song */
|
||||
$song = Song::factory()->create(['path' => realpath(__DIR__ . '/../../songs/full.mp3')]);
|
||||
|
||||
$songZipArchive = new SongZipArchive();
|
||||
|
|
|
@ -38,11 +38,11 @@ class InteractionServiceTest extends TestCase
|
|||
{
|
||||
$this->expectsEvents(SongLikeToggled::class);
|
||||
|
||||
/** @var Interaction $interaction */
|
||||
$interaction = Interaction::factory()->create();
|
||||
|
||||
$this->interactionService->toggleLike($interaction->song, $interaction->user);
|
||||
|
||||
/** @var Interaction $interaction */
|
||||
$updatedInteraction = Interaction::find($interaction->id);
|
||||
self::assertNotSame($interaction->liked, $updatedInteraction->liked);
|
||||
}
|
||||
|
|
|
@ -56,9 +56,12 @@ class LastfmServiceTest extends TestCase
|
|||
|
||||
public function testGetAlbumInformation(): void
|
||||
{
|
||||
/** @var Artist $artist */
|
||||
$artist = Artist::factory()->create(['name' => 'bar']);
|
||||
|
||||
/** @var Album $album */
|
||||
$album = Album::factory()->create([
|
||||
'artist_id' => Artist::factory()->create(['name' => 'bar'])->id,
|
||||
'artist_id' => $artist->id,
|
||||
'name' => 'foo',
|
||||
]);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class MediaMetadataServiceTest extends TestCase
|
|||
{
|
||||
copy(__DIR__ . '/../../blobs/cover.png', album_cover_path('album-cover-for-thumbnail-test.jpg'));
|
||||
|
||||
/** @var Album $album */
|
||||
$album = Album::factory()->create(['cover' => 'album-cover-for-thumbnail-test.jpg']);
|
||||
|
||||
self::assertSame(
|
||||
|
@ -31,6 +32,7 @@ class MediaMetadataServiceTest extends TestCase
|
|||
|
||||
public function testGetAlbumThumbnailUrlWithNoCover(): void
|
||||
{
|
||||
/** @var Album $album */
|
||||
$album = Album::factory()->create(['cover' => null]);
|
||||
self::assertNull(app(MediaMetadataService::class)->getAlbumThumbnailUrl($album));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class S3ServiceTest extends TestCase
|
|||
|
||||
public function testGetSongPublicUrl(): void
|
||||
{
|
||||
/** @var Song $song */
|
||||
$song = Song::factory()->create(['path' => 's3://foo/bar']);
|
||||
|
||||
$cmd = Mockery::mock(CommandInterface::class);
|
||||
|
|
Loading…
Reference in a new issue