From 76a90bed27a80c76409df09d679cca8b23a789d4 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 12 Jun 2020 09:14:04 -0400
Subject: [PATCH] Add alias support to mock container.

---
 .../VuFindTest/Container/MockContainer.php    | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/module/VuFind/src/VuFindTest/Container/MockContainer.php b/module/VuFind/src/VuFindTest/Container/MockContainer.php
index a24fa314c3a..4aa4a0a6460 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);
     }
-- 
GitLab