diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php index 8c4d7895860ef91af57e4c2bb8619a2516c4b711..759096c7a62af436f0fcdc65f8d587d82ead8d4c 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter.php @@ -178,7 +178,7 @@ class RecordDataFormatter extends AbstractHelper return $method; } - $useCache = isset($options['cacheData']) && $options['cacheData']; + $useCache = isset($options['useCache']) && $options['useCache']; if ($useCache) { $cacheKey = $driver->getUniqueID() . '|' 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 c2b022974910545a427b76abeeb9ed99a0a1b602..23bdb096d76ee3d98f7b22717b8e084c4c6225ae 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 @@ -92,8 +92,11 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase protected function getDriver($overrides = []) { // "Mock out" tag functionality to avoid database access: + $methods = [ + 'getBuilding', 'getDeduplicatedAuthors', 'getContainerTitle', 'getTags' + ]; $record = $this->getMockBuilder('VuFind\RecordDriver\SolrDefault') - ->setMethods(['getBuilding', 'getContainerTitle', 'getTags']) + ->setMethods($methods) ->getMock(); $record->expects($this->any())->method('getTags') ->will($this->returnValue([])); @@ -103,6 +106,15 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase ->will($this->returnValue(0)); $record->expects($this->any())->method('getContainerTitle') ->will($this->returnValue('0')); + // Expect only one call to getDeduplicatedAuthors to confirm that caching + // works correctly (we need this data more than once, but should only pull + // it from the driver once). + $authors = [ + 'primary' => ['Vico, Giambattista, 1668-1744.' => []], + 'secondary' => ['Pandolfi, Claudia.' => []], + ]; + $record->expects($this->once())->method('getDeduplicatedAuthors') + ->will($this->returnValue($authors)); // Load record data from fixture file: $fixture = json_decode(