From 791d57051ad4d5fd6f24a0e8c200ca1fc8555c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 1 Dec 2021 19:08:58 +0100 Subject: [PATCH] Adapt tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/public/Util.php | 2 ++ tests/lib/UtilTest.php | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/public/Util.php b/lib/public/Util.php index f77f8a58370..d0b23ddd3e0 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -232,6 +232,8 @@ class Util { /** * Return the list of scripts injected to the page + * @return array + * @since 24.0.0 */ public static function getScripts(): array { // merging first and last data set diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index ca7a4ad1442..1b430fd7ecd 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -225,30 +225,35 @@ class UtilTest extends \Test\TestCase { \OC_Util::$scripts = []; \OC_Util::$styles = []; + self::invokePrivate(\OCP\Util::class, 'scripts', [[]]); } protected function tearDown(): void { parent::tearDown(); \OC_Util::$scripts = []; \OC_Util::$styles = []; + self::invokePrivate(\OCP\Util::class, 'scripts', [[]]); } public function testAddScript() { - \OC_Util::addScript('core', 'myFancyJSFile1'); - \OC_Util::addScript('myApp', 'myFancyJSFile2'); - \OC_Util::addScript('core', 'myFancyJSFile0', true); - \OC_Util::addScript('core', 'myFancyJSFile10', true); + \OCP\Util::addScript('core', 'myFancyJSFile1'); + \OCP\Util::addScript('files', 'myFancyJSFile2', 'core'); + \OCP\Util::addScript('myApp', 'myFancyJSFile3'); + \OCP\Util::addScript('core', 'myFancyJSFile4'); + // after itself + \OCP\Util::addScript('core', 'myFancyJSFile5', 'core'); // add duplicate - \OC_Util::addScript('core', 'myFancyJSFile1'); + \OCP\Util::addScript('core', 'myFancyJSFile1'); $this->assertEquals([ - 'core/js/myFancyJSFile10', - 'core/js/myFancyJSFile0', 'core/js/myFancyJSFile1', + 'core/js/myFancyJSFile4', + 'files/js/myFancyJSFile2', + 'core/js/myFancyJSFile5', + 'files/l10n/en', 'myApp/l10n/en', - 'myApp/js/myFancyJSFile2', - ], \OC_Util::$scripts); - $this->assertEquals([], \OC_Util::$styles); + 'myApp/js/myFancyJSFile3', + ], array_values(\OCP\Util::getScripts())); } public function testAddVendorScript() {