mirror of
https://github.com/koel/koel
synced 2025-02-17 13:58:28 +00:00
fix: static analytics
This commit is contained in:
parent
72a6f2b17f
commit
7861478f12
11 changed files with 15 additions and 14 deletions
|
@ -8,6 +8,7 @@ use App\Models\Song;
|
|||
use App\Models\User;
|
||||
use App\Services\InteractionService;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class LikeMultipleSongsController extends Controller
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ class LikeMultipleSongsController extends Controller
|
|||
InteractionService $interactionService,
|
||||
Authenticatable $user
|
||||
) {
|
||||
/** @var Collection|array<array-key, Song> $songs */
|
||||
$songs = Song::query()->findMany($request->songs);
|
||||
$songs->each(fn (Song $song) => $this->authorize('access', $song));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class CommunityLicenseService implements LicenseServiceInterface
|
|||
throw MethodNotImplementedException::method(__METHOD__);
|
||||
}
|
||||
|
||||
public function getStatus(): LicenseStatus
|
||||
public function getStatus(bool $checkCache = true): LicenseStatus
|
||||
{
|
||||
throw MethodNotImplementedException::method(__METHOD__);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class FakePlusLicenseService implements LicenseServiceInterface
|
|||
throw MethodNotImplementedException::method(__METHOD__);
|
||||
}
|
||||
|
||||
public function getStatus(): LicenseStatus
|
||||
public function getStatus(bool $checkCache = true): LicenseStatus
|
||||
{
|
||||
throw MethodNotImplementedException::method(__METHOD__);
|
||||
}
|
||||
|
|
|
@ -15,5 +15,5 @@ interface LicenseServiceInterface
|
|||
|
||||
public function deactivate(License $license): void;
|
||||
|
||||
public function getStatus(): LicenseStatus;
|
||||
public function getStatus(bool $checkCache = true): LicenseStatus;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class SongFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'album_id' => Album::factory(),
|
||||
'artist_id' => static fn (array $attributes) => Album::find($attributes['album_id'])->artist_id,
|
||||
'artist_id' => static fn (array $attributes) => Album::find($attributes['album_id'])->artist_id, // @phpstan-ignore-line
|
||||
'title' => $this->faker->sentence,
|
||||
'length' => $this->faker->randomFloat(2, 10, 500),
|
||||
'track' => random_int(1, 20),
|
||||
|
|
|
@ -27,6 +27,8 @@ parameters:
|
|||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Factories\\Factory::#'
|
||||
- '#expects App\\Models\\User\|null, Illuminate\\Database\\Eloquent\\Collection\|Illuminate\\Database\\Eloquent\\Model given#'
|
||||
- '#Method App\\Models\\.*::query\(\) should return App\\Builders\\.*Builder but returns Illuminate\\Database\\Eloquent\\Builder<Illuminate\\Database\\Eloquent\\Model>#'
|
||||
- '#Parameter \#1 \$callback of method Illuminate\\Support\\Collection<int,Illuminate\\Database\\Eloquent\\Model>::each\(\) expects callable\(Illuminate\\Database\\Eloquent\\Model, int\)#'
|
||||
|
||||
|
||||
excludePaths:
|
||||
- ./routes/console.php
|
||||
|
|
|
@ -47,7 +47,7 @@ class InteractionTest extends TestCase
|
|||
{
|
||||
$this->withoutEvents();
|
||||
|
||||
/** @var User $user */
|
||||
/** @var User $owner */
|
||||
$owner = User::factory()->create();
|
||||
|
||||
// Can't like a private song that doesn't belong to the user
|
||||
|
@ -73,7 +73,7 @@ class InteractionTest extends TestCase
|
|||
{
|
||||
$this->withoutEvents();
|
||||
|
||||
/** @var User $user */
|
||||
/** @var User $owner */
|
||||
$owner = User::factory()->create();
|
||||
|
||||
// Can't batch like private songs that don't belong to the user
|
||||
|
@ -104,7 +104,7 @@ class InteractionTest extends TestCase
|
|||
{
|
||||
$this->withoutEvents();
|
||||
|
||||
/** @var User $user */
|
||||
/** @var User $owner */
|
||||
$owner = User::factory()->create();
|
||||
|
||||
// Can't batch unlike private songs that don't belong to the user
|
||||
|
|
|
@ -76,10 +76,10 @@ class SongPlayTest extends TestCase
|
|||
]);
|
||||
|
||||
/** @var User $owner */
|
||||
$user = User::factory()->create();
|
||||
$owner = User::factory()->create();
|
||||
|
||||
/** @var CompositeToken $token */
|
||||
$token = app(TokenManager::class)->createCompositeToken($user);
|
||||
$token = app(TokenManager::class)->createCompositeToken($owner);
|
||||
|
||||
$this->get("play/$song->id?t=$token->audioToken")
|
||||
->assertForbidden();
|
||||
|
|
|
@ -34,6 +34,7 @@ class SongTest extends TestCase
|
|||
// We can access our own private songs.
|
||||
$this->getAs('api/songs/' . $ownPrivateSong->id, $user)->assertSuccessful();
|
||||
|
||||
/** @var Song $externalUnownedSong */
|
||||
$externalUnownedSong = Song::factory()->private()->create();
|
||||
|
||||
// But we can't access private songs that are not ours.
|
||||
|
|
|
@ -10,7 +10,7 @@ class SongVisibilityTest extends TestCase
|
|||
{
|
||||
public function testChangingVisibilityIsForbiddenInCommunityEdition(): void
|
||||
{
|
||||
/** @var User $user */
|
||||
/** @var User $owner */
|
||||
$owner = User::factory()->admin()->create();
|
||||
|
||||
Song::factory(3)->create();
|
||||
|
|
|
@ -5,10 +5,6 @@ namespace Tests\Traits;
|
|||
use App\Models\User;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
|
||||
/**
|
||||
* @extends TestCase
|
||||
*/
|
||||
|
||||
trait MakesHttpRequests
|
||||
{
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue