mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
chore: fix static analysis problems
This commit is contained in:
parent
560d41bf1d
commit
50a94cb4b9
73 changed files with 158 additions and 363 deletions
|
@ -36,23 +36,9 @@ class Application extends IlluminateApplication
|
|||
if (isset($manifest[$file])) {
|
||||
return file_exists(public_path('hot'))
|
||||
? "http://localhost:8080{$manifest[$file]}"
|
||||
: $this->staticUrl("{$manifest[$file]}");
|
||||
: static_url("{$manifest[$file]}");
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a URL for static file requests.
|
||||
* If this installation of Koel has a CDN_URL configured, use it as the base.
|
||||
* Otherwise, just use a full URL to the asset.
|
||||
*
|
||||
* @param string $name the additional resource name/path
|
||||
*/
|
||||
public function staticUrl(?string $name = null): string
|
||||
{
|
||||
$cdnUrl = trim(config('koel.cdn.url'), '/ ');
|
||||
|
||||
return $cdnUrl ? $cdnUrl . '/' . trim(ltrim($name, '/')) : trim(asset($name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,22 @@ class SmartPlaylistRuleParameterFactory
|
|||
Rule::OPERATOR_IS_GREATER_THAN => [$model, '>', $value[0]],
|
||||
Rule::OPERATOR_IS_BETWEEN => [$model, $value],
|
||||
Rule::OPERATOR_NOT_IN_LAST => static function () use ($model, $value): array {
|
||||
return [$model, '<', (new Carbon())->subDay($value[0])];
|
||||
return [$model, '<', (new Carbon())->subDays($value[0])];
|
||||
},
|
||||
Rule::OPERATOR_IN_LAST => static function () use ($model, $value): array {
|
||||
return [$model, '>=', (new Carbon())->subDay($value[0])];
|
||||
return [$model, '>=', (new Carbon())->subDays($value[0])];
|
||||
},
|
||||
];
|
||||
|
||||
throw_unless(array_key_exists($operator, $ruleParameterMap), InvalidArgumentException::class, sprintf(
|
||||
'Invalid operator %s. Valid operators are: %s.',
|
||||
$operator,
|
||||
implode(', ', array_keys($ruleParameterMap))
|
||||
));
|
||||
throw_unless(
|
||||
array_key_exists($operator, $ruleParameterMap),
|
||||
InvalidArgumentException::class,
|
||||
sprintf(
|
||||
'Invalid operator %s. Valid operators are: %s.',
|
||||
$operator,
|
||||
implode(', ', array_keys($ruleParameterMap))
|
||||
)
|
||||
);
|
||||
|
||||
return is_array($ruleParameterMap[$operator]) ? $ruleParameterMap[$operator] : $ruleParameterMap[$operator]();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
/**
|
||||
* Get a URL for static file requests.
|
||||
* If this installation of Koel has a CDN_URL configured, use it as the base.
|
||||
* Otherwise, just use a full URL to the asset.
|
||||
*
|
||||
* @param string $name The optional resource name/path
|
||||
*/
|
||||
function static_url(?string $name = null): string
|
||||
{
|
||||
$cdnUrl = trim(config('koel.cdn.url'), '/ ');
|
||||
|
||||
return $cdnUrl ? $cdnUrl . '/' . trim(ltrim($name, '/')) : trim(asset($name));
|
||||
}
|
||||
|
||||
function album_cover_path(string $fileName): string
|
||||
{
|
||||
|
@ -9,7 +21,7 @@ function album_cover_path(string $fileName): string
|
|||
|
||||
function album_cover_url(string $fileName): string
|
||||
{
|
||||
return app()->staticUrl(config('koel.album_cover_dir') . $fileName);
|
||||
return static_url(config('koel.album_cover_dir') . $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,5 +39,5 @@ function artist_image_path(string $fileName): string
|
|||
|
||||
function artist_image_url(string $fileName): string
|
||||
{
|
||||
return app()->staticUrl(config('koel.artist_image_dir') . $fileName);
|
||||
return static_url(config('koel.artist_image_dir') . $fileName);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class AuthController extends Controller
|
|||
|
||||
public function login(UserLoginRequest $request)
|
||||
{
|
||||
/** @var User $user */
|
||||
/** @var User|null $user */
|
||||
$user = $this->userRepository->getFirstWhere('email', $request->email);
|
||||
|
||||
if (!$user || !$this->hash->check($request->password, $user->password)) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class DataController extends Controller
|
|||
'allowDownload' => config('koel.download.allow'),
|
||||
'supportsTranscoding' => config('koel.streaming.ffmpeg_path')
|
||||
&& is_executable(config('koel.streaming.ffmpeg_path')),
|
||||
'cdnUrl' => app()->staticUrl(),
|
||||
'cdnUrl' => static_url(),
|
||||
'currentVersion' => Application::KOEL_VERSION,
|
||||
'latestVersion' => $this->currentUser->is_admin
|
||||
? $this->applicationInformationService->getLatestVersionNumber()
|
||||
|
|
|
@ -48,9 +48,10 @@ class PlaylistController extends Controller
|
|||
$playlist->songs()->sync($songs);
|
||||
}
|
||||
|
||||
$playlist->songs = $playlist->songs->pluck('id');
|
||||
$playlistAsArray = $playlist->toArray();
|
||||
$playlistAsArray['songs'] = $playlist->songs->pluck('id');
|
||||
|
||||
return response()->json($playlist);
|
||||
return response()->json($playlistAsArray);
|
||||
}
|
||||
|
||||
public function update(Request $request, Playlist $playlist)
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
|
@ -16,7 +15,8 @@ class Authenticate
|
|||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
/** @return mixed */
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax() || $request->route()->getName() === 'play') {
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ForceHttps
|
||||
{
|
||||
|
@ -16,7 +15,8 @@ class ForceHttps
|
|||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
/** @return mixed */
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (config('koel.force_https')) {
|
||||
$this->url->forceScheme('https');
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Authenticate requests from Object Storage services (like S3).
|
||||
|
@ -12,7 +11,8 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
*/
|
||||
class ObjectStorageAuthenticate
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
/** @return mixed */
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($request->appKey !== config('app.key')) {
|
||||
return response('Unauthorized.', 401);
|
||||
|
|
|
@ -15,9 +15,7 @@ class RedirectIfAuthenticated
|
|||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
/** @return mixed */
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check()) {
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Requests\API;
|
|||
|
||||
/**
|
||||
* @property string $q
|
||||
* @property string api_token
|
||||
* @property string $api_token
|
||||
*/
|
||||
class ViewSongOnITunesRequest extends Request
|
||||
{
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
class JWTEventListener
|
||||
{
|
||||
public function onValidUser(Dispatcher $event): void
|
||||
{
|
||||
auth()->setUser($event->user);
|
||||
}
|
||||
|
||||
public function subscribe(Dispatcher $events): void
|
||||
{
|
||||
$events->listen('tymon.jwt.valid', self::class . '@onValidUser');
|
||||
}
|
||||
}
|
|
@ -10,9 +10,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use function App\Helpers\album_cover_path;
|
||||
use function App\Helpers\album_cover_url;
|
||||
|
||||
/**
|
||||
* @property string $cover The album cover's file name
|
||||
* @property string|null $cover_path The absolute path to the cover file
|
||||
|
|
|
@ -11,9 +11,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
use function App\Helpers\artist_image_path;
|
||||
use function App\Helpers\artist_image_url;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
|
@ -29,6 +26,7 @@ use function App\Helpers\artist_image_url;
|
|||
* @method static Builder where(...$params)
|
||||
* @method static self first()
|
||||
* @method static Builder whereName(string $name)
|
||||
* @method static Builder orderBy(...$params)
|
||||
*/
|
||||
class Artist extends Model
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ use Illuminate\Support\Collection;
|
|||
* @property string $id
|
||||
* @property int $artist_id
|
||||
* @property int $mtime
|
||||
* @property int $contributing_artist_id
|
||||
*
|
||||
* @method static self updateOrCreate(array $where, array $params)
|
||||
* @method static Builder select(string $string)
|
||||
|
@ -109,7 +110,7 @@ class Song extends Model
|
|||
$single = count($ids) === 1;
|
||||
|
||||
foreach ($ids as $id) {
|
||||
/** @var Song $song */
|
||||
/** @var Song|null $song */
|
||||
$song = self::with('album', 'album.artist')->find($id);
|
||||
|
||||
if (!$song) {
|
||||
|
|
|
@ -14,18 +14,11 @@ class SongZipArchive
|
|||
/** @var ZipArchive */
|
||||
private $archive;
|
||||
|
||||
/**
|
||||
* Path to the zip archive.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* Names of the files in the archive
|
||||
* Format: [file-name.mp3' => currentFileIndex].
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fileNames = [];
|
||||
|
||||
|
@ -40,19 +33,15 @@ class SongZipArchive
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple songs into the archive.
|
||||
*/
|
||||
public function addSongs(Collection $songs): self
|
||||
{
|
||||
$songs->each([$this, 'addSong']);
|
||||
$songs->each(function (Song $song): void {
|
||||
$this->addSong($song);
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single song into the archive.
|
||||
*/
|
||||
public function addSong(Song $song): self
|
||||
{
|
||||
try {
|
||||
|
@ -65,9 +54,6 @@ class SongZipArchive
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish (close) the archive.
|
||||
*/
|
||||
public function finish(): self
|
||||
{
|
||||
$this->archive->close();
|
||||
|
|
|
@ -46,7 +46,7 @@ abstract class AbstractRepository implements RepositoryInterface
|
|||
return $this->model->all();
|
||||
}
|
||||
|
||||
public function getFirstWhere(...$params): Model
|
||||
public function getFirstWhere(...$params): ?Model
|
||||
{
|
||||
return $this->model->where(...$params)->first();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ class InteractionRepository extends AbstractRepository
|
|||
'liked' => true,
|
||||
])
|
||||
->with('song')
|
||||
->get()
|
||||
->pluck('song');
|
||||
}
|
||||
|
||||
|
@ -42,9 +41,6 @@ class InteractionRepository extends AbstractRepository
|
|||
$query = $query->take($count);
|
||||
}
|
||||
|
||||
return $query
|
||||
->get()
|
||||
->pluck('song_id')
|
||||
->all();
|
||||
return $query->pluck('song_id')->all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,12 +238,12 @@ class LastfmService extends AbstractApiClient implements ApiConsumerInterface
|
|||
*
|
||||
* @see http://www.last.fm/api/webauth#5
|
||||
*
|
||||
* @param array $params the array of parameters
|
||||
* @param array $params The array of parameters
|
||||
* @param bool $toString Whether to turn the array into a query string
|
||||
*
|
||||
* @return array<mixed>|string
|
||||
*/
|
||||
public function buildAuthCallParams(array $params, bool $toString = false): string
|
||||
public function buildAuthCallParams(array $params, bool $toString = false)
|
||||
{
|
||||
$params['api_key'] = $this->getKey();
|
||||
ksort($params);
|
||||
|
|
|
@ -7,9 +7,6 @@ use App\Models\Artist;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
use function App\Helpers\album_cover_path;
|
||||
use function App\Helpers\artist_image_path;
|
||||
|
||||
class MediaMetadataService
|
||||
{
|
||||
private $imageWriter;
|
||||
|
|
|
@ -25,7 +25,7 @@ class UserFactory extends Factory
|
|||
|
||||
public function admin(): self
|
||||
{
|
||||
return $this->state(static function (): array {
|
||||
return $this->state(function (): array { // phpcs:ignore
|
||||
return ['is_admin' => true];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', static function (Blueprint $table): void {
|
||||
|
@ -22,10 +19,6 @@ class CreateUsersTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('users');
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('password_resets', static function (Blueprint $table): void {
|
||||
|
@ -18,10 +15,6 @@ class CreatePasswordResetsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('password_resets');
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateArtistsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('artists', static function (Blueprint $table): void {
|
||||
|
@ -18,10 +15,6 @@ class CreateArtistsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('artists');
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreateAlbumsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('albums', static function (Blueprint $table): void {
|
||||
|
@ -25,10 +21,6 @@ class CreateAlbumsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('albums');
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreateSongsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('songs', static function (Blueprint $table): void {
|
||||
|
@ -28,10 +24,6 @@ class CreateSongsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('songs');
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreatePlaylistsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('playlists', static function (Blueprint $table): void {
|
||||
|
@ -24,10 +20,6 @@ class CreatePlaylistsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('playlists');
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreateInteractionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('interactions', static function (Blueprint $table): void {
|
||||
|
@ -27,10 +23,6 @@ class CreateInteractionsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('interactions');
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreatePlaylistSongTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('playlist_song', static function (Blueprint $table): void {
|
||||
|
@ -24,10 +20,6 @@ class CreatePlaylistSongTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('playlist_song');
|
||||
|
|
|
@ -5,24 +5,15 @@ use Illuminate\Database\Schema\Blueprint;
|
|||
|
||||
class CreateSettingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', static function (Blueprint $table): void {
|
||||
$table->string('key');
|
||||
$table->text('value');
|
||||
|
||||
$table->primary('key');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::drop('settings');
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddPreferencesToUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', static function (Blueprint $table): void {
|
||||
|
@ -16,10 +13,6 @@ class AddPreferencesToUsersTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', static function (Blueprint $table): void {
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddImageToArtistsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('artists', static function (Blueprint $table): void {
|
||||
|
@ -16,10 +13,6 @@ class AddImageToArtistsTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('artists', static function (Blueprint $table): void {
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTrackIntoSongs extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
|
@ -16,10 +13,6 @@ class AddTrackIntoSongs extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsComplilationIntoAlbums extends Migration
|
||||
{
|
||||
|
@ -12,7 +13,7 @@ class AddIsComplilationIntoAlbums extends Migration
|
|||
public function up(): void
|
||||
{
|
||||
Schema::table('albums', static function (Blueprint $table): void {
|
||||
$table->boolean('is_compilation')->nullable()->defaults(false)->after('cover');
|
||||
$table->boolean('is_compilation')->nullable()->default(false)->after('cover');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddContributingArtistIdIntoSongs extends Migration
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
use App\Models\Artist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateVariousArtists extends Migration
|
||||
{
|
||||
|
@ -14,7 +16,7 @@ class CreateVariousArtists extends Migration
|
|||
{
|
||||
// Make sure modified artists cascade the album's artist_id field.
|
||||
Schema::table('albums', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
if (DB::getDriverName() !== 'sqlite') { // @phpstan-ignore-line
|
||||
$table->dropForeign('albums_artist_id_foreign');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,17 +2,15 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CascadeDeleteUser extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('playlists', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
if (DB::getDriverName() !== 'sqlite') { // @phpstan-ignore-line
|
||||
$table->dropForeign('playlists_user_id_foreign');
|
||||
}
|
||||
|
||||
|
@ -20,14 +18,10 @@ class CascadeDeleteUser extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('playlists', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
if (DB::getDriverName() !== 'sqlite') { // @phpstan-ignore-line
|
||||
$table->dropForeign('playlists_user_id_foreign');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,30 +2,24 @@
|
|||
|
||||
use App\Models\Artist;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FixArtistAutoindexValue extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// This is to fix the auto increment bug caused by 2016_04_16_082627_create_various_artists
|
||||
|
||||
// Return if the database driver is not MySQL.
|
||||
if (DB::getDriverName() !== 'mysql') {
|
||||
if (DB::getDriverName() !== 'mysql') { // @phpstan-ignore-line
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Artist $latestArtist */
|
||||
$latestArtist = Artist::orderBy('id', 'DESC')->first();
|
||||
DB::statement('ALTER TABLE artists AUTO_INCREMENT=' . ($latestArtist->id + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,10 +5,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class CopyArtistToContributingArtist extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Song::with('album', 'album.artist')->get()->each(static function (Song $song): void {
|
||||
|
@ -19,10 +15,6 @@ class CopyArtistToContributingArtist extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class DropIsComplicationFromAlbums extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('albums', static function (Blueprint $table): void {
|
||||
|
@ -17,10 +13,6 @@ class DropIsComplicationFromAlbums extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
|
|
@ -2,18 +2,15 @@
|
|||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RenameContributingArtistId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
if (DB::getDriverName() !== 'sqlite') { // @phpstan-ignore-line
|
||||
$table->dropForeign(['contributing_artist_id']);
|
||||
}
|
||||
|
||||
|
@ -29,7 +26,7 @@ class RenameContributingArtistId extends Migration
|
|||
public function down(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
if (DB::getDriverName() !== 'sqlite') { // @phpstan-ignore-line
|
||||
$table->dropForeign(['contributing_artist_id']);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class AddDiscIntoSongs extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
|
@ -17,10 +13,6 @@ class AddDiscIntoSongs extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('songs', static function (Blueprint $table): void {
|
||||
|
|
|
@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class AddRulesIntoPlaylists extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('playlists', static function (Blueprint $table): void {
|
||||
|
@ -16,9 +13,6 @@ class AddRulesIntoPlaylists extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('playlists', static function (Blueprint $table): void {
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class CreatePersonalAccessTokensTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', static function (Blueprint $table): void {
|
||||
|
@ -23,10 +19,6 @@ class CreatePersonalAccessTokensTable extends Migration
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
|
|
|
@ -12,12 +12,12 @@ parameters:
|
|||
level: 5
|
||||
|
||||
ignoreErrors:
|
||||
- '#\(Modules\\Core\\Entities\\User(\|null)?\) does not accept Illuminate\\Contracts\\Auth\\Authenticatable#'
|
||||
- '#\(App\\Models\\User(\|null)?\) does not accept Illuminate\\Contracts\\Auth\\Authenticatable#'
|
||||
- '#PHPDoc tag @return with type array\|Illuminate\\Support\\Collection is not subtype of native type Illuminate\\Support\\Collection#'
|
||||
- '#Unsafe usage of new static#'
|
||||
- '#is not subtype of native type (Illuminate\\Support|Illuminate\\Database\\Eloquent)\\Collection#'
|
||||
- '#expects Countable\|iterable, Illuminate\\Contracts\\Pagination\\LengthAwarePaginator given#'
|
||||
- '#expects Modules\\Core\\Entities\\User\|null, Illuminate\\Contracts\\Auth\\Authenticatable\|null given#'
|
||||
- '#expects App\\Models\\User\|null, Illuminate\\Contracts\\Auth\\Authenticatable\|null given#'
|
||||
- '#expects .*, Mockery\\LegacyMockInterface given#'
|
||||
- '#Call to an undefined method Illuminate\\Filesystem\\FilesystemAdapter::getAdapter\(\)#'
|
||||
- '#Call to an undefined method Mockery\\ExpectationInterface|Mockery\\HigherOrderMessage::with\(\)#'
|
||||
|
@ -28,6 +28,7 @@ parameters:
|
|||
|
||||
excludes_analyse:
|
||||
- ./routes/console.php
|
||||
- ./app/Services/Util.php
|
||||
|
||||
checkMissingIterableValueType: false
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
|
|
|
@ -1,32 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
cacheResult="true"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" cacheResult="true"
|
||||
backupStaticAttributes="false" bootstrap="bootstrap/autoload.php" colors="true"
|
||||
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
|
||||
processIsolation="false" stopOnFailure="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./app/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="integration">
|
||||
<directory suffix="Test.php">./tests/Integration</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./app/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_URL" value="http://localhost/"/>
|
||||
|
@ -43,7 +36,6 @@
|
|||
<env name="ADMIN_PASSWORD" value="SoSecureK0el"/>
|
||||
<env name="BROADCAST_DRIVER" value="log"/>
|
||||
<env name="CACHE_MEDIA" value="true"/>
|
||||
|
||||
<ini name="memory_limit" value="512M" />
|
||||
<ini name="memory_limit" value="512M"/>
|
||||
</php>
|
||||
</phpunit>
|
|
@ -12,11 +12,11 @@
|
|||
<meta name="msapplication-navbutton-color" content="#282828">
|
||||
|
||||
<base href="{{ asset('') }}">
|
||||
<link rel="manifest" href="{{ App::staticUrl('manifest.json') }}" />
|
||||
<meta name="msapplication-config" content="{{ App::staticUrl('browserconfig.xml') }}" />
|
||||
<link rel="icon" type="image/x-icon" href="{{ App::staticUrl('img/favicon.ico') }}" />
|
||||
<link rel="icon" href="{{ App::staticUrl('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ App::staticUrl('img/icon.png') }}">
|
||||
<link rel="manifest" href="{{ static_url('manifest.json') }}" />
|
||||
<meta name="msapplication-config" content="{{ static_url('browserconfig.xml') }}" />
|
||||
<link rel="icon" type="image/x-icon" href="{{ static_url('img/favicon.ico') }}" />
|
||||
<link rel="icon" href="{{ static_url('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ static_url('img/icon.png') }}">
|
||||
|
||||
<link rel="stylesheet" href="{{ App::rev('/css/app.css') }}">
|
||||
</head>
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
<meta name="msapplication-navbutton-color" content="#282828">
|
||||
|
||||
<base href="{{ asset('') }}">
|
||||
<link rel="manifest" href="{{ App::staticUrl('manifest-remote.json') }}" />
|
||||
<meta name="msapplication-config" content="{{ App::staticUrl('browserconfig.xml') }}" />
|
||||
<link rel="icon" type="image/x-icon" href="{{ App::staticUrl('img/favicon.ico') }}" />
|
||||
<link rel="icon" href="{{ App::staticUrl('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ App::staticUrl('img/icon.png') }}">
|
||||
<link rel="manifest" href="{{ static_url('manifest-remote.json') }}" />
|
||||
<meta name="msapplication-config" content="{{ static_url('browserconfig.xml') }}" />
|
||||
<link rel="icon" type="image/x-icon" href="{{ static_url('img/favicon.ico') }}" />
|
||||
<link rel="icon" href="{{ static_url('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ static_url('img/icon.png') }}">
|
||||
|
||||
<link rel="stylesheet" href="{{ App::rev('/css/remote.css') }}">
|
||||
</head>
|
||||
|
|
|
@ -16,7 +16,7 @@ class AlbumCoverTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaMetadataService = static::mockIocDependency(MediaMetadataService::class);
|
||||
$this->mediaMetadataService = self::mock(MediaMetadataService::class);
|
||||
}
|
||||
|
||||
public function testUpdate(): void
|
||||
|
|
|
@ -14,7 +14,7 @@ class AlbumThumbnailTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaMetadataService = self::mockIocDependency(MediaMetadataService::class);
|
||||
$this->mediaMetadataService = self::mock(MediaMetadataService::class);
|
||||
}
|
||||
|
||||
/** @return array<mixed> */
|
||||
|
|
|
@ -18,7 +18,7 @@ class ArtistImageTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaMetadataService = static::mockIocDependency(MediaMetadataService::class);
|
||||
$this->mediaMetadataService = self::mock(MediaMetadataService::class);
|
||||
}
|
||||
|
||||
public function testUpdate(): void
|
||||
|
|
|
@ -28,7 +28,7 @@ class DownloadTest extends TestCase
|
|||
parent::setUp();
|
||||
|
||||
static::createSampleMediaSet();
|
||||
$this->downloadService = static::mockIocDependency(DownloadService::class);
|
||||
$this->downloadService = self::mock(DownloadService::class);
|
||||
}
|
||||
|
||||
public function testNonLoggedInUserCannotDownload(): void
|
||||
|
@ -165,7 +165,7 @@ class DownloadTest extends TestCase
|
|||
$user = User::factory()->create();
|
||||
$favorites = Collection::make();
|
||||
|
||||
static::mockIocDependency(InteractionRepository::class)
|
||||
self::mock(InteractionRepository::class)
|
||||
->shouldReceive('getUserFavorites')
|
||||
->once()
|
||||
->with(Mockery::on(static function (User $retrievedUser) use ($user): bool {
|
||||
|
|
|
@ -12,6 +12,7 @@ use Illuminate\Log\Logger;
|
|||
use Laravel\Sanctum\NewAccessToken;
|
||||
use Laravel\Sanctum\PersonalAccessToken;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class LastfmTest extends TestCase
|
||||
{
|
||||
|
@ -42,10 +43,11 @@ class LastfmTest extends TestCase
|
|||
$user = User::factory()->create();
|
||||
$token = $user->createToken('Koel')->plainTextToken;
|
||||
|
||||
/** @var NewAccessToken|MockInterface $temporaryToken */
|
||||
$temporaryToken = Mockery::mock(NewAccessToken::class);
|
||||
$temporaryToken->plainTextToken = 'tmp-token';
|
||||
|
||||
$tokenManager = static::mockIocDependency(TokenManager::class);
|
||||
$tokenManager = self::mock(TokenManager::class);
|
||||
|
||||
$tokenManager->shouldReceive('getUserFromPlainTextToken')
|
||||
->with($token)
|
||||
|
@ -70,7 +72,7 @@ class LastfmTest extends TestCase
|
|||
|
||||
self::assertNotNull(PersonalAccessToken::findToken($token));
|
||||
|
||||
$lastfm = static::mockIocDependency(LastfmService::class);
|
||||
$lastfm = self::mock(LastfmService::class);
|
||||
|
||||
$lastfm->shouldReceive('getSessionKey')
|
||||
->with('lastfm-token')
|
||||
|
@ -90,13 +92,13 @@ class LastfmTest extends TestCase
|
|||
/** @var User $user */
|
||||
$user = User::factory()->create();
|
||||
|
||||
$lastfm = static::mockIocDependency(LastfmService::class);
|
||||
$lastfm = self::mock(LastfmService::class);
|
||||
$lastfm->shouldReceive('getSessionKey')
|
||||
->once()
|
||||
->with('foo')
|
||||
->andReturn('bar');
|
||||
|
||||
$tokenManager = static::mockIocDependency(TokenManager::class);
|
||||
$tokenManager = self::mock(TokenManager::class);
|
||||
$tokenManager->shouldReceive('getUserFromPlainTextToken')
|
||||
->once()
|
||||
->with('my-token')
|
||||
|
|
|
@ -11,6 +11,7 @@ use App\Services\FileSynchronizer;
|
|||
use App\Services\MediaSyncService;
|
||||
use getID3;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Mockery;
|
||||
|
||||
class MediaSyncTest extends TestCase
|
||||
{
|
||||
|
@ -201,19 +202,22 @@ class MediaSyncTest extends TestCase
|
|||
|
||||
public function testHtmlEntities(): void
|
||||
{
|
||||
static::mockIocDependency(getID3::class, [
|
||||
'analyze' => [
|
||||
'tags' => [
|
||||
'id3v2' => [
|
||||
'title' => ['水谷広実'],
|
||||
'album' => ['小岩井こ Random'],
|
||||
'artist' => ['佐倉綾音 Unknown'],
|
||||
$this->swap(
|
||||
getID3::class,
|
||||
Mockery::mock(getID3::class, [
|
||||
'analyze' => [
|
||||
'tags' => [
|
||||
'id3v2' => [
|
||||
'title' => ['水谷広実'],
|
||||
'album' => ['小岩井こ Random'],
|
||||
'artist' => ['佐倉綾音 Unknown'],
|
||||
],
|
||||
],
|
||||
'encoding' => 'UTF-8',
|
||||
'playtime_seconds' => 100,
|
||||
],
|
||||
'encoding' => 'UTF-8',
|
||||
'playtime_seconds' => 100,
|
||||
],
|
||||
]);
|
||||
])
|
||||
);
|
||||
|
||||
/** @var FileSynchronizer $fileSynchronizer */
|
||||
$fileSynchronizer = app(FileSynchronizer::class);
|
||||
|
|
|
@ -13,7 +13,7 @@ class ProfileTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->hash = static::mockIocDependency(Hasher::class);
|
||||
$this->hash = self::mock(Hasher::class);
|
||||
}
|
||||
|
||||
public function testUpdateProfileWithoutPassword(): void
|
||||
|
|
|
@ -20,7 +20,7 @@ class ScrobbleTest extends TestCase
|
|||
|
||||
$timestamp = time();
|
||||
|
||||
static::mockIocDependency(LastfmService::class)
|
||||
self::mock(LastfmService::class)
|
||||
->shouldReceive('scrobble')
|
||||
->with($song->album->artist->name, $song->title, $timestamp, $song->album->name, 'foo')
|
||||
->once();
|
||||
|
|
|
@ -14,7 +14,7 @@ class SettingTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaSyncService = static::mockIocDependency(MediaSyncService::class);
|
||||
$this->mediaSyncService = self::mock(MediaSyncService::class);
|
||||
}
|
||||
|
||||
public function testSaveSettings(): void
|
||||
|
|
|
@ -19,7 +19,7 @@ class UploadTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->uploadService = $this->mockIocDependency(UploadService::class);
|
||||
$this->uploadService = self::mock(UploadService::class);
|
||||
}
|
||||
|
||||
public function testUnauthorizedPost(): void
|
||||
|
|
|
@ -13,7 +13,7 @@ class UserTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->hash = static::mockIocDependency(Hasher::class);
|
||||
$this->hash = self::mock(Hasher::class);
|
||||
}
|
||||
|
||||
public function testNonAdminCannotCreateUser(): void
|
||||
|
|
|
@ -14,7 +14,7 @@ class YouTubeTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->youTubeService = static::mockIocDependency(YouTubeService::class);
|
||||
$this->youTubeService = self::mock(YouTubeService::class);
|
||||
}
|
||||
|
||||
public function testSearchYouTubeVideos(): void
|
||||
|
|
|
@ -10,6 +10,7 @@ use App\Services\Streamers\TranscodingStreamer;
|
|||
use App\Services\Streamers\XAccelRedirectStreamer;
|
||||
use App\Services\Streamers\XSendFileStreamer;
|
||||
use App\Services\TranscodingService;
|
||||
use Mockery;
|
||||
use phpmock\mockery\PHPMockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -36,9 +37,9 @@ class StreamerFactoryTest extends TestCase
|
|||
|
||||
public function testCreateTranscodingStreamerIfSupported(): void
|
||||
{
|
||||
static::mockIocDependency(TranscodingService::class, [
|
||||
$this->swap(TranscodingService::class, Mockery::mock(TranscodingService::class, [
|
||||
'songShouldBeTranscoded' => true,
|
||||
]);
|
||||
]));
|
||||
|
||||
/** @var StreamerFactory $streamerFactory */
|
||||
$streamerFactory = app(StreamerFactory::class);
|
||||
|
@ -50,9 +51,9 @@ class StreamerFactoryTest extends TestCase
|
|||
|
||||
public function testCreateTranscodingStreamerIfForced(): void
|
||||
{
|
||||
static::mockIocDependency(TranscodingService::class, [
|
||||
$this->swap(TranscodingService::class, Mockery::mock(TranscodingService::class, [
|
||||
'songShouldBeTranscoded' => false,
|
||||
]);
|
||||
]));
|
||||
|
||||
/** @var StreamerFactory $streamerFactory */
|
||||
$streamerFactory = app(StreamerFactory::class);
|
||||
|
@ -79,9 +80,9 @@ class StreamerFactoryTest extends TestCase
|
|||
*/
|
||||
public function testCreatePHPStreamer($config, $expectedClass): void
|
||||
{
|
||||
static::mockIocDependency(TranscodingService::class, [
|
||||
$this->swap(TranscodingService::class, Mockery::mock(TranscodingService::class, [
|
||||
'songShouldBeTranscoded' => false,
|
||||
]);
|
||||
]));
|
||||
|
||||
config(['koel.streaming.method' => $config]);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class DownloadAlbumCoverTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaMetaDataService = static::mockIocDependency(MediaMetadataService::class);
|
||||
$this->mediaMetaDataService = self::mock(MediaMetadataService::class);
|
||||
PHPMockery::mock('App\Listeners', 'ini_get')->andReturn(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class DownloadArtistImageTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mediaMetaDataService = static::mockIocDependency(MediaMetadataService::class);
|
||||
$this->mediaMetaDataService = self::mock(MediaMetadataService::class);
|
||||
PHPMockery::mock('App\Listeners', 'ini_get')->andReturn(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ class ApplicationInformationServiceTest extends TestCase
|
|||
$service = new ApplicationInformationService($client, app(Cache::class), app(Logger::class));
|
||||
|
||||
self::assertEquals($latestVersion, $service->getLatestVersionNumber());
|
||||
self::assertSame($latestVersion, cache('latestKoelVersion'));
|
||||
self::assertSame($latestVersion, cache()->get('latestKoelVersion'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,6 @@ class ITunesServiceTest extends TestCase
|
|||
$url
|
||||
);
|
||||
|
||||
self::assertNotNull(cache('b57a14784d80c58a856e0df34ff0c8e2'));
|
||||
self::assertNotNull(cache()->get('b57a14784d80c58a856e0df34ff0c8e2'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class LastfmServiceTest extends TestCase
|
|||
],
|
||||
], $info);
|
||||
|
||||
self::assertNotNull(cache('0aff3bc1259154f0e9db860026cda7a6'));
|
||||
self::assertNotNull(cache()->get('0aff3bc1259154f0e9db860026cda7a6'));
|
||||
}
|
||||
|
||||
public function testGetArtistInformationForNonExistentArtist(): void
|
||||
|
@ -70,7 +70,6 @@ class LastfmServiceTest extends TestCase
|
|||
$api = new LastfmService($client, app(Cache::class), app(Logger::class));
|
||||
$info = $api->getAlbumInformation($album->name, $album->artist->name);
|
||||
|
||||
// Then I get the album's info
|
||||
self::assertEquals([
|
||||
'url' => 'https://www.last.fm/music/Kamelot/Epica',
|
||||
'image' => 'http://foo.bar/extralarge.jpg',
|
||||
|
@ -92,7 +91,7 @@ class LastfmServiceTest extends TestCase
|
|||
],
|
||||
], $info);
|
||||
|
||||
self::assertNotNull(cache('fca889d13b3222589d7d020669cc5a38'));
|
||||
self::assertNotNull(cache()->get('fca889d13b3222589d7d020669cc5a38'));
|
||||
}
|
||||
|
||||
public function testGetAlbumInformationForNonExistentAlbum(): void
|
||||
|
|
|
@ -6,9 +6,6 @@ use App\Models\Album;
|
|||
use App\Services\MediaMetadataService;
|
||||
use Tests\TestCase;
|
||||
|
||||
use function App\Helpers\album_cover_path;
|
||||
use function App\Helpers\album_cover_url;
|
||||
|
||||
class MediaMetadataServiceTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
|
|
|
@ -25,6 +25,6 @@ class YouTubeServiceTest extends TestCase
|
|||
$response = $api->search('Lorem Ipsum');
|
||||
|
||||
self::assertEquals('Slipknot - Snuff [OFFICIAL VIDEO]', $response->items[0]->snippet->title);
|
||||
self::assertNotNull(cache('1492972ec5c8e6b3a9323ba719655ddb'));
|
||||
self::assertNotNull(cache()->get('1492972ec5c8e6b3a9323ba719655ddb'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use ReflectionClass;
|
||||
use Tests\Traits\CreatesApplication;
|
||||
use Tests\Traits\InteractsWithIoc;
|
||||
use Tests\Traits\SandboxesTests;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
|
@ -18,7 +17,6 @@ abstract class TestCase extends BaseTestCase
|
|||
use ArraySubsetAsserts;
|
||||
use CreatesApplication;
|
||||
use DatabaseTransactions;
|
||||
use InteractsWithIoc;
|
||||
use SandboxesTests;
|
||||
|
||||
public function setUp(): void
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Traits;
|
||||
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
trait InteractsWithIoc
|
||||
{
|
||||
/**
|
||||
* Mock an IOC dependency, for example an injected service in controllers.
|
||||
*/
|
||||
protected static function mockIocDependency(string $abstract, ...$args): MockInterface
|
||||
{
|
||||
return tap(Mockery::mock($abstract, ...$args), static function (MockInterface $mocked) use ($abstract): void {
|
||||
app()->instance($abstract, $mocked);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -17,16 +17,16 @@ class ApplicationTest extends TestCase
|
|||
{
|
||||
config(['koel.cdn.url' => '']);
|
||||
|
||||
self::assertEquals('http://localhost/', app()->staticUrl());
|
||||
self::assertEquals('http://localhost/foo.css', app()->staticUrl('/foo.css '));
|
||||
self::assertEquals('http://localhost/', static_url());
|
||||
self::assertEquals('http://localhost/foo.css', static_url('/foo.css '));
|
||||
}
|
||||
|
||||
public function testStaticUrlsWithCdnAreConstructedCorrectly(): void
|
||||
{
|
||||
config(['koel.cdn.url' => 'http://cdn.tld']);
|
||||
|
||||
self::assertEquals('http://cdn.tld/', app()->staticUrl());
|
||||
self::assertEquals('http://cdn.tld/foo.css', app()->staticUrl('/foo.css '));
|
||||
self::assertEquals('http://cdn.tld/', static_url());
|
||||
self::assertEquals('http://cdn.tld/foo.css', static_url('/foo.css '));
|
||||
}
|
||||
|
||||
public function testApplicationAssetRevisionUrlsAreConstructedCorrectlyWhenNotUsingCdn(): void
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Http\Middleware\ForceHttps;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Mockery;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ForceHttpsTest extends TestCase
|
||||
|
@ -32,11 +33,13 @@ class ForceHttpsTest extends TestCase
|
|||
$request->shouldReceive('setTrustedProxies')
|
||||
->with(['127.0.0.1'], Request::HEADER_X_FORWARDED_ALL);
|
||||
|
||||
$next = static function (Request $request): Request {
|
||||
return $request;
|
||||
$response = Mockery::mock(Response::class);
|
||||
|
||||
$next = static function () use ($response): Response {
|
||||
return $response;
|
||||
};
|
||||
|
||||
self::assertSame($request, $this->middleware->handle($request, $next));
|
||||
self::assertSame($response, $this->middleware->handle($request, $next));
|
||||
}
|
||||
|
||||
public function testNotHandle(): void
|
||||
|
@ -48,10 +51,12 @@ class ForceHttpsTest extends TestCase
|
|||
$request = Mockery::mock(Request::class);
|
||||
$request->shouldReceive('setTrustedProxies')->never();
|
||||
|
||||
$next = static function (Request $request): Request {
|
||||
return $request;
|
||||
$response = Mockery::mock(Response::class);
|
||||
|
||||
$next = static function () use ($response): Response {
|
||||
return $response;
|
||||
};
|
||||
|
||||
self::assertSame($request, $this->middleware->handle($request, $next));
|
||||
self::assertSame($response, $this->middleware->handle($request, $next));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,6 @@ use Illuminate\Log\Logger;
|
|||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
use function App\Helpers\album_cover_url;
|
||||
use function App\Helpers\artist_image_url;
|
||||
|
||||
class MediaMetadataServiceTest extends TestCase
|
||||
{
|
||||
private $mediaMetadataService;
|
||||
|
|
Loading…
Reference in a new issue