From a6acf69585426421cc46e22840d4f92018fde40e Mon Sep 17 00:00:00 2001 From: Christian Einvik Date: Wed, 19 Jul 2023 12:43:15 +0200 Subject: [PATCH] Update unittest for EditorStorage --- .../Libraries/H5P/EditorStorageTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sourcecode/apis/contentauthor/tests/Integration/Libraries/H5P/EditorStorageTest.php b/sourcecode/apis/contentauthor/tests/Integration/Libraries/H5P/EditorStorageTest.php index ad851aeea7..02409b95e5 100644 --- a/sourcecode/apis/contentauthor/tests/Integration/Libraries/H5P/EditorStorageTest.php +++ b/sourcecode/apis/contentauthor/tests/Integration/Libraries/H5P/EditorStorageTest.php @@ -99,4 +99,27 @@ public function provider_getLibraries(): \Generator ] ]; } + + public function test_getLanguage(): void + { + /** @var H5PLibrary $lib */ + $lib = H5PLibrary::factory()->create(); + H5PLibraryLanguage::factory(1)->create([ + 'library_id' => $lib->id, + ]); + $langCode = H5PLibraryLanguage::factory()->create([ + 'library_id' => $lib->id, + 'translation' => '{"test":"success"}', + ]); + + $es = app(EditorStorage::class); + $result = $es->getLanguage( + $lib->name, + $lib->major_version, + $lib->minor_version, + $langCode->language_code + ); + $translation = json_decode($result, true, flags: JSON_THROW_ON_ERROR); + $this->assertSame('success', $translation['test']); + } }