Skip to content
Snippets Groups Projects
Commit d3dccd2a authored by Ere Maijala's avatar Ere Maijala
Browse files

Added unit tests to cover all MultiBackend driver functionality. Fixed some...

Added unit tests to cover all MultiBackend driver functionality. Fixed some MultiBackend driver issues the added tests revealed.
parent 17e9a09d
No related merge requests found
......@@ -477,7 +477,7 @@ class MultiBackend extends AbstractBase
*/
public function renewMyItems($renewDetails)
{
$source = $this->getSource($renewDetails['patron']['id']);
$source = $this->getSource($renewDetails['patron']['cat_username'], 'login');
$driver = $this->getDriver($source);
if ($driver) {
$details = $driver->renewMyItems(
......@@ -705,7 +705,7 @@ class MultiBackend extends AbstractBase
$source = $this->getSource($bibId);
$driver = $this->getDriver($source);
if ($driver) {
if ($this->getSource($patron['id']) != $source
if ($this->getSource($patron['cat_username'], 'login') != $source
|| !$this->methodSupported($driver, 'getRequestGroups')
) {
// Return empty array since the sources don't match or the method
......@@ -852,7 +852,7 @@ class MultiBackend extends AbstractBase
$source = $this->getSource($details['patron']['cat_username'], 'login');
$driver = $this->getDriver($source);
if ($driver
&& is_callable(driver($driver, 'placeStorageRetrievalRequest'))
&& is_callable(array($driver, 'placeStorageRetrievalRequest'))
) {
if ($this->getSource($details['id']) != $source) {
return array(
......@@ -969,6 +969,7 @@ class MultiBackend extends AbstractBase
$patron
);
}
throw new ILSException('No suitable backend driver found');
}
/**
......@@ -996,6 +997,7 @@ class MultiBackend extends AbstractBase
$patron
);
}
throw new ILSException('No suitable backend driver found');
}
/**
......@@ -1130,7 +1132,9 @@ class MultiBackend extends AbstractBase
// If we have resolved the needed driver, just getConfig and return.
if ($driver && $this->methodSupported($driver, 'getConfig')) {
return $driver->getConfig($function);
return $driver->getConfig(
$function, $this->stripIdPrefixes($id, $source)
);
}
// If driver not available, return an empty array
......@@ -1353,16 +1357,9 @@ class MultiBackend extends AbstractBase
if (!isset($this->isInitialized[$source])
|| !$this->isInitialized[$source]
) {
try
{
$driver->init();
$this->isInitialized[$source] = true;
$this->cache[$source] = $driver;
} catch (Exception $e) {
$this->error(
"Driver init for '$source' failed: " . $e->getMessage()
);
}
$driver->init();
$this->isInitialized[$source] = true;
$this->cache[$source] = $driver;
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment