diff --git a/e107_handlers/library_manager.php b/e107_handlers/library_manager.php index d3a7e214f8..008cd36c35 100755 --- a/e107_handlers/library_manager.php +++ b/e107_handlers/library_manager.php @@ -154,8 +154,8 @@ public function config() ), // Override library path to CDN. 'library_path' => 'https://cdn.jsdelivr.net/jquery.once', - 'path' => '2.1.2', - 'version' => '2.1.2', + 'path' => '2.2.3', + 'version' => '2.2.3', ); // jQuery Once (local). @@ -238,8 +238,8 @@ public function config() ), // Override library path to CDN. 'library_path' => 'https://cdn.jsdelivr.net/jquery.ui', - 'path' => '1.11.4', - 'version' => '1.11.4', + 'path' => '1.12.1', + 'version' => '1.12.1', ); // jQuery UI (local). @@ -929,9 +929,9 @@ public function config() ), 'variants' => array(), // Override library path to CDN. - 'library_path' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0', + 'library_path' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2', 'path' => '', - 'version' => '5.14.0', + 'version' => '5.15.2', ); // Font-Awesome (local). @@ -1094,12 +1094,21 @@ class e_library_manager /** @var array list of callbacks to track performance */ private $callbacks = array(); + /** + * @var e_file + */ + private $fileHandler; + /** * Constructor * Use {@link getInstance()}, direct instantiating is not possible for signleton objects. + * + * @param e_file|null $fileHandler */ - public function __construct() + public function __construct($fileHandler = null) { + if ($fileHandler === null) $fileHandler = e107::getFile(); + $this->fileHandler = $fileHandler; } /** @@ -1534,7 +1543,7 @@ private function getLibraries() $directories = array(); // Retrieve list of directories. - $file = e107::getFile(); + $file = $this->fileHandler; $dirs = $file->get_dirs($dir); foreach($dirs as $dirName) @@ -2182,7 +2191,7 @@ private function getVersion($library, $options) // The library will be cached with version number, so this only run once per library. if(strpos($file, 'http') === 0) { - $content = e107::getFile()->getRemoteContent($file); + $content = $this->fileHandler->getRemoteContent($file); $tmpFile = tempnam(sys_get_temp_dir(), 'lib_'); if($tmpFile) diff --git a/e107_tests/tests/unit/e_library_managerTest.php b/e107_tests/tests/unit/e_library_managerTest.php index 892dca198e..db30158ec8 100644 --- a/e107_tests/tests/unit/e_library_managerTest.php +++ b/e107_tests/tests/unit/e_library_managerTest.php @@ -20,7 +20,15 @@ protected function _before() try { - $this->lib = $this->make('e_library_manager'); + $fakeFile = $this->make('e_file', [ + 'getRemoteContent' => function($url) + { + throw new RuntimeException("Test needs rewriting. Blocked Internet fetch of URL: $url"); + }, + ]); + $this->lib = $this->make('e_library_manager', [ + 'fileHandler' => $fakeFile, + ]); } catch(Exception $e) { @@ -72,7 +80,7 @@ function testDetectionVersionConsistency() foreach($this->libraries as $name) { $coded = $this->lib->detect($name); - $detected = $this->lib->detect($name, true); + $detected = $this->lib->detect(str_replace('cdn.', '', $name), true); if(empty($coded['version'])) {