diff --git a/module/VuFind/src/VuFindTest/Container/MockContainer.php b/module/VuFind/src/VuFindTest/Container/MockContainer.php index a24fa314c3a0f68c2658d37ac3a5a094392580d4..4aa4a0a6460e72417f9d2c9cadaa15b7b2b5fe9a 100644 --- a/module/VuFind/src/VuFindTest/Container/MockContainer.php +++ b/module/VuFind/src/VuFindTest/Container/MockContainer.php @@ -55,6 +55,15 @@ class MockContainer implements ContainerInterface */ protected $services = []; + /** + * Common service aliases. + * + * @var array + */ + protected $aliases = [ + 'ViewHelperManager' => \Laminas\View\HelperPluginManager::class, + ]; + /** * Test case (for building mock objects) * @@ -108,12 +117,13 @@ class MockContainer implements ContainerInterface /** * Finds an entry of the container by its identifier and returns it. * - * @param string $id Identifier of the entry to look for. + * @param string $rawId Identifier of the entry to look for. * * @return mixed */ - public function get($id) + public function get($rawId) { + $id = $this->aliases[$rawId] ?? $rawId; if (!isset($this->services[$id])) { $this->services[$id] = $this->createMock($id); } @@ -124,12 +134,13 @@ class MockContainer implements ContainerInterface * Returns true if the container can return an entry for the given identifier. * Returns false otherwise. * - * @param string $id Identifier of the entry to look for. + * @param string $rawId Identifier of the entry to look for. * * @return bool */ - public function has($id) + public function has($rawId) { + $id = $this->aliases[$rawId] ?? $rawId; // Assume every service exists unless explicitly disabled return !in_array($id, $this->disabled); }