From 94b2275eac414f76c919ee339cbe9324630f4929 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 11 Aug 2026 23:22:03 +0200 Subject: [PATCH] Fix issue in anidb edit page --- resources/views/admin/anidb/edit.blade.php | 46 ++++++------- tests/Feature/AdminAnidbControllerTest.php | 76 ++++++++++++++++++++++ 2 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 tests/Feature/AdminAnidbControllerTest.php diff --git a/resources/views/admin/anidb/edit.blade.php b/resources/views/admin/anidb/edit.blade.php index 94603c4a2..f74a0ffa7 100644 --- a/resources/views/admin/anidb/edit.blade.php +++ b/resources/views/admin/anidb/edit.blade.php @@ -17,10 +17,10 @@
-
+ @csrf - +
@@ -33,7 +33,7 @@
@@ -46,7 +46,7 @@
@@ -58,7 +58,7 @@ @@ -71,7 +71,7 @@ @@ -84,11 +84,11 @@ - @if(!empty($anime['rating'])) + @if(!empty($anime->rating))

- Display: {{ number_format($anime['rating'] / 100, 1) }} / 10 + Display: {{ number_format($anime->rating / 100, 1) }} / 10

@endif @@ -101,7 +101,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->related ?? '' }} @@ -112,7 +112,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->similar ?? '' }} @@ -125,11 +125,11 @@
@php - $hasCover = $anime['anidbid'] > 0 && (file_exists(storage_path('covers/anime/' . $anime['anidbid'] . '-cover.webp')) || file_exists(storage_path('covers/anime/' . $anime['anidbid'] . '-cover.jpg'))); + $hasCover = $anime->anidbid > 0 && (file_exists(storage_path('covers/anime/' . $anime->anidbid . '-cover.webp')) || file_exists(storage_path('covers/anime/' . $anime->anidbid . '-cover.jpg'))); @endphp @if($hasCover) - {{ $anime['title'] }} @else
@@ -143,8 +143,8 @@ @php - $anilistId = $anime['anilist_id'] ?? null; - $malId = $anime['mal_id'] ?? null; + $anilistId = $anime->anilist_id ?? null; + $malId = $anime->mal_id ?? null; @endphp @if(!empty($anilistId) || !empty($malId))
@@ -174,7 +174,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->description ?? '' }}
@@ -185,7 +185,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->creators ?? '' }}
@@ -196,7 +196,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->categories ?? '' }}
@@ -207,7 +207,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->characters ?? '' }} @@ -221,7 +221,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->epnos ?? '' }}
@@ -231,7 +231,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->airdates ?? '' }}
@@ -241,7 +241,7 @@ + class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 rounded-md focus:ring-blue-500 focus:border-blue-500">{{ $anime->episodetitles ?? '' }}
diff --git a/tests/Feature/AdminAnidbControllerTest.php b/tests/Feature/AdminAnidbControllerTest.php new file mode 100644 index 000000000..c1e2bcd4d --- /dev/null +++ b/tests/Feature/AdminAnidbControllerTest.php @@ -0,0 +1,76 @@ +setGlobalViewData([ + 'serverroot' => 'http://localhost', + 'site' => ['dereferrer_link' => ''], + 'usefulLinks' => collect(), + 'isadmin' => true, + 'ismod' => false, + 'loggedin' => false, + 'userTheme' => 'light', + 'userColorScheme' => 'blue', + ]); + } + + protected function tearDown(): void + { + $this->setGlobalViewData(null); + + parent::tearDown(); + } + + public function test_edit_view_renders_database_result_object(): void + { + $anime = (object) [ + 'anidbid' => 123, + 'title' => 'Regression Test Anime', + 'type' => 'TV Series', + 'startdate' => '2026-01-01', + 'enddate' => '2026-03-01', + 'rating' => 825, + 'related' => 'Related title', + 'similar' => 'Similar title', + 'anilist_id' => 456, + 'mal_id' => 789, + 'description' => 'Anime description', + 'creators' => 'Anime creator', + 'categories' => 'Action', + 'characters' => 'Main character', + ]; + + $html = view('admin.anidb.edit', [ + 'anime' => $anime, + 'title' => 'AniDB Edit', + 'meta_title' => 'AniDB Edit', + ])->render(); + + $this->assertStringContainsString('Regression Test Anime', $html); + $this->assertStringContainsString('value="123"', $html); + $this->assertStringContainsString('Display: 8.3 / 10', $html); + } + + /** + * @param array|null $data + */ + private function setGlobalViewData(?array $data): void + { + $reflection = new ReflectionClass(GlobalDataComposer::class); + $property = $reflection->getProperty('resolvedData'); + + $property->setValue(null, $data); + } +}