2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
namespace Tests;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2024-01-03 17:02:18 +00:00
|
|
|
use App\Facades\License;
|
2024-01-09 18:34:40 +00:00
|
|
|
use App\Services\License\CommunityLicenseService;
|
2020-11-14 16:57:25 +00:00
|
|
|
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
2017-08-05 16:56:11 +00:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2017-02-14 06:53:02 +00:00
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
2024-01-09 18:34:40 +00:00
|
|
|
use Illuminate\Support\Facades\File;
|
2020-06-13 12:19:24 +00:00
|
|
|
use Tests\Traits\CreatesApplication;
|
2024-01-09 18:34:40 +00:00
|
|
|
use Tests\Traits\MakesHttpRequests;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
abstract class TestCase extends BaseTestCase
|
|
|
|
{
|
2020-11-14 16:57:25 +00:00
|
|
|
use ArraySubsetAsserts;
|
2020-01-17 16:45:45 +00:00
|
|
|
use CreatesApplication;
|
2020-11-14 16:57:25 +00:00
|
|
|
use DatabaseTransactions;
|
2024-01-09 18:34:40 +00:00
|
|
|
use MakesHttpRequests;
|
2020-01-17 16:46:06 +00:00
|
|
|
|
2019-07-22 07:03:23 +00:00
|
|
|
public function setUp(): void
|
2017-06-10 13:25:30 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
2020-09-09 16:18:53 +00:00
|
|
|
|
2024-01-03 17:02:18 +00:00
|
|
|
License::swap($this->app->make(CommunityLicenseService::class));
|
2020-06-13 12:19:24 +00:00
|
|
|
self::createSandbox();
|
2017-06-10 13:25:30 +00:00
|
|
|
}
|
2018-08-19 11:08:16 +00:00
|
|
|
|
2019-07-22 07:03:23 +00:00
|
|
|
protected function tearDown(): void
|
2018-08-19 11:08:16 +00:00
|
|
|
{
|
2020-06-13 12:19:24 +00:00
|
|
|
self::destroySandbox();
|
2020-12-22 20:11:22 +00:00
|
|
|
|
2018-08-19 11:08:16 +00:00
|
|
|
parent::tearDown();
|
|
|
|
}
|
2020-09-09 16:18:53 +00:00
|
|
|
|
2024-01-09 18:34:40 +00:00
|
|
|
private static function createSandbox(): void
|
|
|
|
{
|
|
|
|
config(['koel.album_cover_dir' => 'sandbox/img/covers/']);
|
|
|
|
config(['koel.artist_image_dir' => 'sandbox/img/artists/']);
|
|
|
|
|
|
|
|
File::ensureDirectoryExists(public_path(config('koel.album_cover_dir')));
|
|
|
|
File::ensureDirectoryExists(public_path(config('koel.artist_image_dir')));
|
|
|
|
File::ensureDirectoryExists(public_path('sandbox/media/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function destroySandbox(): void
|
|
|
|
{
|
|
|
|
File::deleteDirectory(public_path('sandbox'));
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|