From a8709725248cdb5664e06f7cbe142d424bce275c Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 10 Jan 2013 12:37:43 -0500
Subject: [PATCH] Incorporated VuFindHttp module test suite; added missing
 method required by tests.

---
 module/VuFind/tests/phpunit.xml               |  3 +++
 .../VuFindHttp/src/VuFindHttp/HttpService.php | 22 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/module/VuFind/tests/phpunit.xml b/module/VuFind/tests/phpunit.xml
index 63d53bda6b0..75839736a1c 100644
--- a/module/VuFind/tests/phpunit.xml
+++ b/module/VuFind/tests/phpunit.xml
@@ -1,5 +1,8 @@
 <phpunit bootstrap="./bootstrap.php" backupGlobals="false">
   <testsuites>
+    <testsuite name="VuFindHttp">
+      <directory>../../VuFindHttp/tests/unit-tests/src</directory>
+    </testsuite>
     <testsuite name="VuFindUnit">
       <directory>unit-tests/src</directory>
     </testsuite>
diff --git a/module/VuFindHttp/src/VuFindHttp/HttpService.php b/module/VuFindHttp/src/VuFindHttp/HttpService.php
index b17833f3070..27d408c6df5 100644
--- a/module/VuFindHttp/src/VuFindHttp/HttpService.php
+++ b/module/VuFindHttp/src/VuFindHttp/HttpService.php
@@ -57,6 +57,13 @@ class HttpService implements HttpServiceInterface
      */
     protected $proxyConfig;
 
+    /**
+     * Default adapter
+     *
+     * @var \Zend\Http\Client\Adapter\AdapterInterface
+     */
+    protected $defaultAdapter = null;
+
     /**
      * Constructor.
      *
@@ -149,6 +156,18 @@ class HttpService implements HttpServiceInterface
         return $this->post($url, $body, \Zend\Http\Client::ENC_URLENCODED, $timeout);
     }
 
+    /**
+     * Set a default HTTP adapter (primarily for testing purposes).
+     *
+     * @param \Zend\Http\Client\Adapter\AdapterInterface $adapter Adapter
+     *
+     * @return void
+     */
+    public function setDefaultAdapter(\Zend\Http\Client\Adapter\AdapterInterface $adapter)
+    {
+        $this->defaultAdapter = $adapter;
+    }
+
     /**
      * Return a new HTTP client.
      *
@@ -162,6 +181,9 @@ class HttpService implements HttpServiceInterface
     {
         $client = new \Zend\Http\Client();
         $client->setMethod($method);
+        if (null !== $this->defaultAdapter) {
+            $client->setAdapter($this->defaultAdapter);
+        }
         if (null !== $url) {
             $client->setUri($url);
         }
-- 
GitLab