From 67828f430be82dcd971e6b4d41bb9cfa17677fa8 Mon Sep 17 00:00:00 2001 From: Mani <12898705+Maniload@users.noreply.github.com> Date: Sat, 9 Mar 2024 02:55:52 +0100 Subject: [PATCH] clean: Removed settings package which is now fully replaced by feature flags (#620) * clean: Removed settings package which is now fully replaced by feature flags * clean: Remove left-over config values --- .env.example | 2 - .env.example-sail | 2 - app/Constants/Config/WikiConstants.php | 21 --- app/Events/Admin/Setting/SettingCreated.php | 34 ----- app/Events/Admin/Setting/SettingDeleted.php | 32 ---- app/Events/Admin/Setting/SettingEvent.php | 56 ------- app/Events/Admin/Setting/SettingUpdated.php | 48 ------ .../Config/Wiki/WikiFeaturedThemeField.php | 25 ---- app/Http/Api/Schema/Config/WikiSchema.php | 51 ------- .../Controllers/Api/Config/WikiController.php | 42 ------ .../Config/Resource/WikiResource.php | 72 --------- app/Models/Admin/Setting.php | 89 ----------- app/Nova/Resources/Admin/Setting.php | 140 ------------------ app/Policies/Admin/SettingPolicy.php | 73 --------- composer.json | 1 - composer.lock | 71 +-------- config/setting.php | 138 ----------------- config/wiki.php | 17 --- database/factories/Admin/SettingFactory.php | 39 ----- ...017_08_24_000000_create_settings_table.php | 37 ----- .../seeders/Admin/Setting/SettingSeeder.php | 44 ------ .../Auth/Permission/PermissionSeeder.php | 2 - database/seeders/Auth/Role/AdminSeeder.php | 2 - lang/en/nova.php | 4 - routes/api.php | 4 - tests/Feature/Events/Admin/SettingTest.php | 81 ---------- .../Feature/Http/Api/Config/WikiShowTest.php | 98 ------------ tests/Feature/Jobs/Admin/SettingTest.php | 77 ---------- tests/Unit/Models/Admin/SettingTest.php | 26 ---- 29 files changed, 2 insertions(+), 1326 deletions(-) delete mode 100644 app/Constants/Config/WikiConstants.php delete mode 100644 app/Events/Admin/Setting/SettingCreated.php delete mode 100644 app/Events/Admin/Setting/SettingDeleted.php delete mode 100644 app/Events/Admin/Setting/SettingEvent.php delete mode 100644 app/Events/Admin/Setting/SettingUpdated.php delete mode 100644 app/Http/Api/Field/Config/Wiki/WikiFeaturedThemeField.php delete mode 100644 app/Http/Api/Schema/Config/WikiSchema.php delete mode 100644 app/Http/Controllers/Api/Config/WikiController.php delete mode 100644 app/Http/Resources/Config/Resource/WikiResource.php delete mode 100644 app/Models/Admin/Setting.php delete mode 100644 app/Nova/Resources/Admin/Setting.php delete mode 100644 app/Policies/Admin/SettingPolicy.php delete mode 100644 config/setting.php delete mode 100644 database/factories/Admin/SettingFactory.php delete mode 100644 database/migrations/2017_08_24_000000_create_settings_table.php delete mode 100644 database/seeders/Admin/Setting/SettingSeeder.php delete mode 100644 tests/Feature/Events/Admin/SettingTest.php delete mode 100644 tests/Feature/Http/Api/Config/WikiShowTest.php delete mode 100644 tests/Feature/Jobs/Admin/SettingTest.php delete mode 100644 tests/Unit/Models/Admin/SettingTest.php diff --git a/.env.example b/.env.example index e0b014a2f..7ed3193d6 100644 --- a/.env.example +++ b/.env.example @@ -295,7 +295,5 @@ WEB_URL=http://localhost WEB_PATH= # wiki -WIKI_FEATURED_ENTRY= -WIKI_FEATURED_VIDEO= WIKI_LOGIN=http://localhost/login WIKI_RESET_PASSWORD=http://localhost/reset-password diff --git a/.env.example-sail b/.env.example-sail index fc12a78d3..aef8678b9 100644 --- a/.env.example-sail +++ b/.env.example-sail @@ -296,7 +296,5 @@ WEB_URL=http://localhost WEB_PATH= # wiki -WIKI_FEATURED_ENTRY= -WIKI_FEATURED_VIDEO= WIKI_LOGIN=http://localhost/login WIKI_RESET_PASSWORD=http://localhost/reset-password diff --git a/app/Constants/Config/WikiConstants.php b/app/Constants/Config/WikiConstants.php deleted file mode 100644 index c583b0514..000000000 --- a/app/Constants/Config/WikiConstants.php +++ /dev/null @@ -1,21 +0,0 @@ -getSetting(); - - return DiscordMessage::create('', [ - 'description' => "Setting '**{$setting->getName()}**' has been created.", - 'color' => EmbedColor::GREEN->value, - ]); - } -} diff --git a/app/Events/Admin/Setting/SettingDeleted.php b/app/Events/Admin/Setting/SettingDeleted.php deleted file mode 100644 index 524d3d4a1..000000000 --- a/app/Events/Admin/Setting/SettingDeleted.php +++ /dev/null @@ -1,32 +0,0 @@ -getSetting(); - - return DiscordMessage::create('', [ - 'description' => "Setting '**{$setting->getName()}**' has been deleted.", - 'color' => EmbedColor::RED->value, - ]); - } -} diff --git a/app/Events/Admin/Setting/SettingEvent.php b/app/Events/Admin/Setting/SettingEvent.php deleted file mode 100644 index 1520f2d22..000000000 --- a/app/Events/Admin/Setting/SettingEvent.php +++ /dev/null @@ -1,56 +0,0 @@ -setting; - } - - /** - * Get Discord channel the message will be sent to. - * - * @return string - */ - public function getDiscordChannel(): string - { - return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED); - } - - /** - * Determine if the message should be sent. - * - * @return bool - */ - public function shouldSendDiscordMessage(): bool - { - return true; - } -} diff --git a/app/Events/Admin/Setting/SettingUpdated.php b/app/Events/Admin/Setting/SettingUpdated.php deleted file mode 100644 index 583d7c0a7..000000000 --- a/app/Events/Admin/Setting/SettingUpdated.php +++ /dev/null @@ -1,48 +0,0 @@ -initializeEmbedFields($setting); - } - - /** - * Get Discord message payload. - * - * @return DiscordMessage - */ - public function getDiscordMessage(): DiscordMessage - { - $setting = $this->getSetting(); - - return DiscordMessage::create('', [ - 'description' => "Setting '**{$setting->getName()}**' has been updated.", - 'fields' => $this->getEmbedFields(), - 'color' => EmbedColor::YELLOW->value, - ]); - } -} diff --git a/app/Http/Api/Field/Config/Wiki/WikiFeaturedThemeField.php b/app/Http/Api/Field/Config/Wiki/WikiFeaturedThemeField.php deleted file mode 100644 index decc15895..000000000 --- a/app/Http/Api/Field/Config/Wiki/WikiFeaturedThemeField.php +++ /dev/null @@ -1,25 +0,0 @@ -validated()); - - return new WikiResource($query); - } - - /** - * Get the underlying schema. - * - * @return Schema - */ - public function schema(): Schema - { - return new WikiSchema(); - } -} diff --git a/app/Http/Resources/Config/Resource/WikiResource.php b/app/Http/Resources/Config/Resource/WikiResource.php deleted file mode 100644 index 488fe9efd..000000000 --- a/app/Http/Resources/Config/Resource/WikiResource.php +++ /dev/null @@ -1,72 +0,0 @@ -query->getFieldCriteria(static::$wrap); - - if ($criteria === null || $criteria->isAllowedField(WikiConstants::FEATURED_THEME_SETTING)) { - /** @var AnimeThemeEntryVideo|null $pivot */ - $pivot = AnimeThemeEntryVideo::query() - ->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, Config::get('wiki.featured_entry')) - ->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, Config::get('wiki.featured_video')) - ->with([ - AnimeThemeEntryVideo::RELATION_ANIME, - AnimeThemeEntryVideo::RELATION_ARTISTS, - AnimeThemeEntryVideo::RELATION_IMAGES, - AnimeThemeEntryVideo::RELATION_SONG, - AnimeThemeEntryVideo::RELATION_VIDEO, - ]) - ->first(); - - $result[WikiConstants::FEATURED_THEME_SETTING] = new AnimeThemeEntryVideoResource($pivot, $this->query); - } - - return $result; - } -} diff --git a/app/Models/Admin/Setting.php b/app/Models/Admin/Setting.php deleted file mode 100644 index b6e86dd9b..000000000 --- a/app/Models/Admin/Setting.php +++ /dev/null @@ -1,89 +0,0 @@ - SettingCreated::class, - 'deleted' => SettingDeleted::class, - 'updated' => SettingUpdated::class, - ]; - - /** - * The table associated with the model. - * - * @var string - */ - protected $table = Setting::TABLE; - - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = Setting::ATTRIBUTE_ID; - - /** - * Get name. - * - * @return string - */ - public function getName(): string - { - return $this->key; - } -} diff --git a/app/Nova/Resources/Admin/Setting.php b/app/Nova/Resources/Admin/Setting.php deleted file mode 100644 index 0de7cd83c..000000000 --- a/app/Nova/Resources/Admin/Setting.php +++ /dev/null @@ -1,140 +0,0 @@ -sortable() - ->showOnPreview() - ->showWhenPeeking(), - - Text::make(__('nova.fields.setting.key'), SettingModel::ATTRIBUTE_KEY) - ->sortable() - ->copyable() - ->rules(['required', 'max:192']) - ->showOnPreview() - ->filterable() - ->maxlength(192) - ->enforceMaxlength() - ->showWhenPeeking(), - - Text::make(__('nova.fields.setting.value'), SettingModel::ATTRIBUTE_VALUE) - ->sortable() - ->copyable() - ->rules(['required', 'max:65535']) - ->showOnPreview() - ->filterable() - ->maxlength(65535) - ->enforceMaxlength() - ->showWhenPeeking(), - ]; - } -} diff --git a/app/Policies/Admin/SettingPolicy.php b/app/Policies/Admin/SettingPolicy.php deleted file mode 100644 index cbe90252f..000000000 --- a/app/Policies/Admin/SettingPolicy.php +++ /dev/null @@ -1,73 +0,0 @@ -can(CrudPermission::VIEW->format(Setting::class)); - } - - /** - * Determine whether the user can view the model. - * - * @param User $user - * @return bool - */ - public function view(User $user): bool - { - return $user->can(CrudPermission::VIEW->format(Setting::class)); - } - - /** - * Determine whether the user can create models. - * - * @param User $user - * @return bool - */ - public function create(User $user): bool - { - return $user->can(CrudPermission::CREATE->format(Setting::class)); - } - - /** - * Determine whether the user can update the model. - * - * @param User $user - * @return bool - */ - public function update(User $user): bool - { - return $user->can(CrudPermission::UPDATE->format(Setting::class)); - } - - /** - * Determine whether the user can delete the model. - * - * @param User $user - * @return bool - */ - public function delete(User $user): bool - { - return $user->can(CrudPermission::DELETE->format(Setting::class)); - } -} diff --git a/composer.json b/composer.json index aa66391b5..e8b7832ad 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "ext-gd": "*", "ext-intl": "*", "ext-pdo": "*", - "akaunting/laravel-setting": "^1.2", "babenkoivan/elastic-migrations": "^3.3", "babenkoivan/elastic-scout-driver-plus": "^4.3", "bepsvpt/secure-headers": "^7.4", diff --git a/composer.lock b/composer.lock index ea07af39c..258718696 100644 --- a/composer.lock +++ b/composer.lock @@ -4,75 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "279efd9eda924e0365bf45eb667d29ad", + "content-hash": "dfa287f156f616dad184bfc915642153", "packages": [ - { - "name": "akaunting/laravel-setting", - "version": "1.2.8", - "source": { - "type": "git", - "url": "https://github.com/akaunting/laravel-setting.git", - "reference": "598cacc042cb5081366f03e5229edbe2a2f17cdf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/akaunting/laravel-setting/zipball/598cacc042cb5081366f03e5229edbe2a2f17cdf", - "reference": "598cacc042cb5081366f03e5229edbe2a2f17cdf", - "shasum": "" - }, - "require": { - "laravel/framework": ">=5.3", - "php": ">=5.5.9" - }, - "require-dev": { - "laravel/framework": ">=5.3", - "mockery/mockery": "0.9.*", - "phpunit/phpunit": ">=4.8" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Akaunting\\Setting\\Provider" - ], - "aliases": { - "Setting": "Akaunting\\Setting\\Facade" - } - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Akaunting\\Setting\\": "./src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Denis Duliçi", - "email": "info@akaunting.com", - "homepage": "https://akaunting.com", - "role": "Developer" - } - ], - "description": "Persistent settings package for Laravel", - "keywords": [ - "Settings", - "config", - "laravel", - "persistent" - ], - "support": { - "issues": "https://github.com/akaunting/laravel-setting/issues", - "source": "https://github.com/akaunting/laravel-setting/tree/1.2.8" - }, - "time": "2022-09-23T10:56:17+00:00" - }, { "name": "aws/aws-crt-php", "version": "v1.2.1", @@ -12260,5 +12193,5 @@ "ext-pcntl": "8.2", "ext-posix": "8.2" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/config/setting.php b/config/setting.php deleted file mode 100644 index 4b46db164..000000000 --- a/config/setting.php +++ /dev/null @@ -1,138 +0,0 @@ - false, - - /* - |-------------------------------------------------------------------------- - | Cache - |-------------------------------------------------------------------------- - | - | Options for caching. Set whether to enable cache, its key, time to live - | in seconds and whether to auto clear after save. - | - */ - 'cache' => [ - 'enabled' => false, - 'key' => 'setting', - 'ttl' => 3600, - 'auto_clear' => true, - ], - - /* - |-------------------------------------------------------------------------- - | Setting driver - |-------------------------------------------------------------------------- - | - | Select where to store the settings. - | - | Supported: "database", "json", "memory" - | - */ - 'driver' => 'database', - - /* - |-------------------------------------------------------------------------- - | Database driver - |-------------------------------------------------------------------------- - | - | Options for database driver. Enter which connection to use, null means - | the default connection. Set the table and column names. - | - */ - 'database' => [ - 'connection' => null, - 'table' => Setting::TABLE, - 'key' => Setting::ATTRIBUTE_KEY, - 'value' => Setting::ATTRIBUTE_VALUE, - ], - - /* - |-------------------------------------------------------------------------- - | JSON driver - |-------------------------------------------------------------------------- - | - | Options for json driver. Enter the full path to the .json file. - | - */ - 'json' => [ - 'path' => storage_path().'/settings.json', - ], - - /* - |-------------------------------------------------------------------------- - | Override application config values - |-------------------------------------------------------------------------- - | - | If defined, settings package will override these config values. - | - | Sample: - | "app.locale" => "settings.locale", - | - */ - 'override' => [ - WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED => WikiConstants::FEATURED_ENTRY_SETTING, - WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED => WikiConstants::FEATURED_VIDEO_SETTING, - ], - - /* - |-------------------------------------------------------------------------- - | Fallback - |-------------------------------------------------------------------------- - | - | Define fallback settings to be used in case the default is null - | - | Sample: - | "currency" => "USD", - | - */ - 'fallback' => [ - - ], - - /* - |-------------------------------------------------------------------------- - | Required Extra Columns - |-------------------------------------------------------------------------- - | - | The list of columns required to be set up - | - | Sample: - | "user_id", - | "tenant_id", - | - */ - 'required_extra_columns' => [ - - ], - - /* - |-------------------------------------------------------------------------- - | Encryption - |-------------------------------------------------------------------------- - | - | Define the keys which should be crypt automatically. - | - | Sample: - | "payment.key" - | - */ - 'encrypted_keys' => [ - - ], - -]; diff --git a/config/wiki.php b/config/wiki.php index 88031062a..8dbc1895f 100644 --- a/config/wiki.php +++ b/config/wiki.php @@ -4,23 +4,6 @@ declare(strict_types=1); return [ - /* - |-------------------------------------------------------------------------- - | Featured Theme - |-------------------------------------------------------------------------- - | - | On the home page of the wiki client, there is a component for a featured theme. - | The featured theme will showcase an OP/ED picked by staff or patrons. - | The video for the featured theme will play muted, blurred and looped in the background of the page. - | To resolve the featured theme, we need to provide the desired pivot row between entry and video. - | To resolve the desired pivot row, these values should correspond to the primary keys of the respective models. - | - */ - - 'featured_entry' => (int) env('WIKI_FEATURED_ENTRY'), - - 'featured_video' => (int) env('WIKI_FEATURED_VIDEO'), - /* |-------------------------------------------------------------------------- | Wiki Routes diff --git a/database/factories/Admin/SettingFactory.php b/database/factories/Admin/SettingFactory.php deleted file mode 100644 index efe1fd875..000000000 --- a/database/factories/Admin/SettingFactory.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class SettingFactory extends Factory -{ - /** - * The name of the factory's corresponding model. - * - * @var class-string - */ - protected $model = Setting::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - Setting::ATTRIBUTE_KEY => fake()->slug(), - Setting::ATTRIBUTE_VALUE => fake()->word(), - ]; - } -} diff --git a/database/migrations/2017_08_24_000000_create_settings_table.php b/database/migrations/2017_08_24_000000_create_settings_table.php deleted file mode 100644 index aef3bf1a2..000000000 --- a/database/migrations/2017_08_24_000000_create_settings_table.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->string(Setting::ATTRIBUTE_KEY)->index(); - $table->text(Setting::ATTRIBUTE_VALUE); - }); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down(): void - { - Schema::dropIfExists(Setting::TABLE); - } -}; diff --git a/database/seeders/Admin/Setting/SettingSeeder.php b/database/seeders/Admin/Setting/SettingSeeder.php deleted file mode 100644 index eb51de2b4..000000000 --- a/database/seeders/Admin/Setting/SettingSeeder.php +++ /dev/null @@ -1,44 +0,0 @@ -firstOrCreate( - [ - Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_ENTRY_SETTING, - ], - [ - Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_ENTRY_SETTING, - Setting::ATTRIBUTE_VALUE => Config::get(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, ''), - ] - ); - - Setting::query()->firstOrCreate( - [ - Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_VIDEO_SETTING, - ], - [ - Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_VIDEO_SETTING, - Setting::ATTRIBUTE_VALUE => Config::get(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, ''), - ] - ); - } -} diff --git a/database/seeders/Auth/Permission/PermissionSeeder.php b/database/seeders/Auth/Permission/PermissionSeeder.php index 9bdad6d8e..751305f3c 100644 --- a/database/seeders/Auth/Permission/PermissionSeeder.php +++ b/database/seeders/Auth/Permission/PermissionSeeder.php @@ -11,7 +11,6 @@ use App\Models\Admin\Announcement; use App\Models\Admin\Dump; use App\Models\Admin\Feature; use App\Models\Admin\FeaturedTheme; -use App\Models\Admin\Setting; use App\Models\Auth\Permission; use App\Models\Auth\Role; use App\Models\Auth\User; @@ -53,7 +52,6 @@ class PermissionSeeder extends Seeder // Admin Resources $this->registerResource(Announcement::class, $extendedCrudPermissions); $this->registerResource(Dump::class, $extendedCrudPermissions); - $this->registerResource(Setting::class, CrudPermission::cases()); $this->registerResource(Feature::class, CrudPermission::cases()); $this->registerResource(FeaturedTheme::class, $extendedCrudPermissions); diff --git a/database/seeders/Auth/Role/AdminSeeder.php b/database/seeders/Auth/Role/AdminSeeder.php index a678adc72..c1988df5f 100644 --- a/database/seeders/Auth/Role/AdminSeeder.php +++ b/database/seeders/Auth/Role/AdminSeeder.php @@ -11,7 +11,6 @@ use App\Models\Admin\Announcement; use App\Models\Admin\Dump; use App\Models\Admin\Feature; use App\Models\Admin\FeaturedTheme; -use App\Models\Admin\Setting; use App\Models\Auth\Permission; use App\Models\Auth\Role; use App\Models\Auth\User; @@ -58,7 +57,6 @@ class AdminSeeder extends RoleSeeder $this->configureResource($role, Announcement::class, $extendedCrudPermissions); $this->configureResource($role, Dump::class, $extendedCrudPermissions); $this->configureResource($role, Feature::class, [CrudPermission::VIEW, CrudPermission::UPDATE]); - $this->configureResource($role, Setting::class, CrudPermission::cases()); $this->configureResource($role, FeaturedTheme::class, $extendedCrudPermissions); // Auth Resources diff --git a/lang/en/nova.php b/lang/en/nova.php index 61f7a704c..c35956267 100644 --- a/lang/en/nova.php +++ b/lang/en/nova.php @@ -657,10 +657,6 @@ return [ 'name' => 'Slug', ], ], - 'setting' => [ - 'key' => 'Key', - 'value' => 'Value', - ], 'song' => [ 'title' => [ 'help' => 'The title of the song', diff --git a/routes/api.php b/routes/api.php index d09c2d818..450ca93ae 100644 --- a/routes/api.php +++ b/routes/api.php @@ -9,7 +9,6 @@ use App\Http\Controllers\Api\Admin\FeatureController; use App\Http\Controllers\Api\Admin\FeaturedThemeController; use App\Http\Controllers\Api\Auth\User\Me\List\MyPlaylistController; use App\Http\Controllers\Api\Auth\User\Me\MyController; -use App\Http\Controllers\Api\Config\WikiController; use App\Http\Controllers\Api\Document\PageController; use App\Http\Controllers\Api\List\Playlist\TrackBackwardController; use App\Http\Controllers\Api\List\Playlist\TrackController; @@ -232,9 +231,6 @@ Route::apiResource('feature', FeatureController::class) Route::get('/me', [MyController::class, 'show'])->name('me.show'); Route::get('/me/playlist', [MyPlaylistController::class, 'index'])->name('me.playlist.index'); -// Config Routes -Route::get('config/wiki', [WikiController::class, 'show'])->name('config.wiki.show'); - // Document Routes apiResourceWhere('page', PageController::class, ['page' => '[\pL\pM\pN\/_-]+']); diff --git a/tests/Feature/Events/Admin/SettingTest.php b/tests/Feature/Events/Admin/SettingTest.php deleted file mode 100644 index ad4520c34..000000000 --- a/tests/Feature/Events/Admin/SettingTest.php +++ /dev/null @@ -1,81 +0,0 @@ -create(); - - Event::assertDispatched(SettingCreated::class); - } - - /** - * When a Setting is deleted, a SettingDeleted event shall be dispatched. - * - * @return void - */ - public function testSettingDeletedEventDispatched(): void - { - $setting = Setting::factory()->create(); - - $setting->delete(); - - Event::assertDispatched(SettingDeleted::class); - } - - /** - * When a Setting is updated, a SettingUpdated event shall be dispatched. - * - * @return void - */ - public function testSettingUpdatedEventDispatched(): void - { - $setting = Setting::factory()->createOne(); - $changes = Setting::factory()->makeOne(); - - $setting->fill($changes->getAttributes()); - $setting->save(); - - Event::assertDispatched(SettingUpdated::class); - } - - /** - * The SettingUpdated event shall contain embed fields. - * - * @return void - */ - public function testSettingUpdatedEventEmbedFields(): void - { - $setting = Setting::factory()->createOne(); - $changes = Setting::factory()->makeOne(); - - $setting->fill($changes->getAttributes()); - $setting->save(); - - Event::assertDispatched(SettingUpdated::class, function (SettingUpdated $event) { - $message = $event->getDiscordMessage(); - - return ! empty(Arr::get($message->embed, 'fields')); - }); - } -} diff --git a/tests/Feature/Http/Api/Config/WikiShowTest.php b/tests/Feature/Http/Api/Config/WikiShowTest.php deleted file mode 100644 index 8fbe95614..000000000 --- a/tests/Feature/Http/Api/Config/WikiShowTest.php +++ /dev/null @@ -1,98 +0,0 @@ -for(Video::factory()) - ->for(AnimeThemeEntry::factory()->for(AnimeTheme::factory()->for(Anime::factory()))) - ->createOne(); - - Config::set(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, $pivot->entry_id); - Config::set(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, $pivot->video_id); - - $response = $this->get(route('api.config.wiki.show')); - - $response->assertJson( - json_decode( - json_encode( - (new WikiResource(new Query())) - ->response() - ->getData() - ), - true - ) - ); - } - - /** - * The Wiki Show Endpoint shall implement sparse fieldsets. - * - * @return void - */ - public function testSparseFieldsets(): void - { - $pivot = AnimeThemeEntryVideo::factory() - ->for(Video::factory()) - ->for(AnimeThemeEntry::factory()->for(AnimeTheme::factory()->for(Anime::factory()))) - ->createOne(); - - Config::set(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, $pivot->entry_id); - Config::set(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, $pivot->video_id); - - $schema = new WikiSchema(); - - $fields = collect($schema->fields()); - - $includedFields = $fields->random($this->faker->numberBetween(1, $fields->count())); - - $parameters = [ - FieldParser::param() => [ - WikiResource::$wrap => $includedFields->map(fn (Field $field) => $field->getKey())->join(','), - ], - ]; - - $response = $this->get(route('api.config.wiki.show')); - - $response->assertJson( - json_decode( - json_encode( - (new WikiResource(new Query($parameters))) - ->response() - ->getData() - ), - true - ) - ); - } -} diff --git a/tests/Feature/Jobs/Admin/SettingTest.php b/tests/Feature/Jobs/Admin/SettingTest.php deleted file mode 100644 index fe0e1f271..000000000 --- a/tests/Feature/Jobs/Admin/SettingTest.php +++ /dev/null @@ -1,77 +0,0 @@ -createOne(); - - Bus::assertDispatched(SendDiscordNotificationJob::class); - } - - /** - * When a setting is deleted, a SendDiscordNotification job shall be dispatched. - * - * @return void - */ - public function testSettingDeletedSendsDiscordNotification(): void - { - $setting = Setting::factory()->createOne(); - - Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); - Bus::fake(SendDiscordNotificationJob::class); - Event::fakeExcept(SettingDeleted::class); - - $setting->delete(); - - Bus::assertDispatched(SendDiscordNotificationJob::class); - } - - /** - * When a setting is updated, a SendDiscordNotification job shall be dispatched. - * - * @return void - */ - public function testSettingUpdatedSendsDiscordNotification(): void - { - $setting = Setting::factory()->createOne(); - - Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); - Bus::fake(SendDiscordNotificationJob::class); - Event::fakeExcept(SettingUpdated::class); - - $changes = Setting::factory()->makeOne(); - - $setting->fill($changes->getAttributes()); - $setting->save(); - - Bus::assertDispatched(SendDiscordNotificationJob::class); - } -} diff --git a/tests/Unit/Models/Admin/SettingTest.php b/tests/Unit/Models/Admin/SettingTest.php deleted file mode 100644 index 702ceb423..000000000 --- a/tests/Unit/Models/Admin/SettingTest.php +++ /dev/null @@ -1,26 +0,0 @@ -createOne(); - - static::assertIsString($setting->getName()); - } -}