From 8c2e08b8c92ecd689cfe7c00f7e2bd4b856d3755 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 9 Jan 2020 09:29:12 -0500
Subject: [PATCH] Prevent notices in PHP 5.4.

---
 .../src/VuFind/Recommend/EuropeanaResults.php  |  2 +-
 .../Helper/Root/RecordDataFormatterTest.php    | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
index be9a7515eee..a8fdf54ed80 100644
--- a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
+++ b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php
@@ -233,7 +233,7 @@ class EuropeanaResults implements RecommendInterface,
                 $resultsProcessed[] = [
                     'title' => $value->getTitle(),
                     'link' => $link,
-                    'enclosure' => $value->getEnclosure()['url']
+                    'enclosure' => $value->getEnclosure()['url'] ?? null
                 ];
             }
             if (count($resultsProcessed) == $this->limit) {
diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
index a40b62396ae..98c3676a86f 100644
--- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
+++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php
@@ -41,6 +41,22 @@ use VuFind\View\Helper\Root\RecordDataFormatterFactory;
  */
 class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase
 {
+    /**
+     * Get a mock record router.
+     *
+     * @return \VuFind\Record\Router
+     */
+    protected function getMockRecordRouter()
+    {
+        $mock = $this->getMockBuilder(\VuFind\Record\Router::class)
+            ->disableOriginalConstructor()
+            ->setMethods(['getActionRouteDetails'])
+            ->getMock();
+        $mock->expects($this->any())->method('getActionRouteDetails')
+            ->will($this->returnValue(['route' => 'home', 'params' => []]));
+        return $mock;
+    }
+
     /**
      * Get view helpers needed by test.
      *
@@ -59,7 +75,7 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase
             'openUrl' => new \VuFind\View\Helper\Root\OpenUrl($context, [], $this->getMockBuilder(\VuFind\Resolver\Driver\PluginManager::class)->disableOriginalConstructor()->getMock()),
             'proxyUrl' => new \VuFind\View\Helper\Root\ProxyUrl(),
             'record' => new \VuFind\View\Helper\Root\Record(),
-            'recordLink' => new \VuFind\View\Helper\Root\RecordLink($this->getMockBuilder(\VuFind\Record\Router::class)->disableOriginalConstructor()->getMock()),
+            'recordLink' => new \VuFind\View\Helper\Root\RecordLink($this->getMockRecordRouter()),
             'searchOptions' => new \VuFind\View\Helper\Root\SearchOptions(new \VuFind\Search\Options\PluginManager($this->getServiceManager())),
             'searchTabs' => $this->getMockBuilder(\VuFind\View\Helper\Root\SearchTabs::class)->disableOriginalConstructor()->getMock(),
             'transEsc' => new \VuFind\View\Helper\Root\TransEsc(),
-- 
GitLab