[Pkg-owncloud-commits] [php-sabredav] 45/66: Unittests should be OK again.

David Prévot taffit at moszumanska.debian.org
Sat Jan 18 20:08:21 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 9be39e864db6f31695a7a7faff043c18ea571f83
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Tue Jan 7 20:52:49 2014 +0100

    Unittests should be OK again.
---
 lib/Sabre/DAV/Server.php                              | 15 ++++++++++++---
 tests/Sabre/CalDAV/ICSExportPluginTest.php            |  9 +++++++++
 tests/Sabre/CalDAV/PluginTest.php                     |  1 +
 tests/Sabre/CalDAV/ValidateICalTest.php               |  1 +
 tests/Sabre/CardDAV/AbstractPluginTest.php            |  2 ++
 tests/Sabre/CardDAV/ValidateVCardTest.php             |  1 +
 tests/Sabre/DAV/AbstractServer.php                    |  3 +--
 tests/Sabre/DAV/Auth/PluginTest.php                   |  1 +
 tests/Sabre/DAV/Issue33Test.php                       |  1 +
 tests/Sabre/DAV/Locks/MSWordTest.php                  |  1 +
 tests/Sabre/DAV/ServerCopyMoveTest.php                |  1 +
 tests/Sabre/DAVACL/ExpandPropertiesTest.php           |  1 +
 tests/Sabre/DAVACL/PluginAdminTest.php                |  2 ++
 tests/Sabre/DAVACL/PrincipalPropertySearchTest.php    |  1 +
 tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php |  1 +
 tests/Sabre/DAVServerTest.php                         |  4 +++-
 tests/Sabre/HTTP/ResponseMock.php                     |  9 ---------
 tests/Sabre/HTTP/{ResponseMock.php => SapiMock.php}   | 11 ++---------
 tests/bootstrap.php                                   |  1 +
 19 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/lib/Sabre/DAV/Server.php b/lib/Sabre/DAV/Server.php
index b882be3..fefd209 100644
--- a/lib/Sabre/DAV/Server.php
+++ b/lib/Sabre/DAV/Server.php
@@ -67,6 +67,13 @@ class Server extends EventEmitter {
     public $httpRequest;
 
     /**
+     * PHP HTTP Sapi
+     *
+     * @var Sabre\HTTP\Sapi
+     */
+    public $sapi;
+
+    /**
      * The list of plugins
      *
      * @var array
@@ -208,8 +215,10 @@ class Server extends EventEmitter {
         } else {
             throw new Exception('Invalid argument passed to constructor. Argument must either be an instance of Sabre\\DAV\\Tree, Sabre\\DAV\\INode, an array or null');
         }
+
+        $this->sapi = new HTTP\Sapi();
         $this->httpResponse = new HTTP\Response();
-        $this->httpRequest = HTTP\Sapi::getRequest();
+        $this->httpRequest = $this->sapi->getRequest();
         $this->addPlugin(new CorePlugin());
 
     }
@@ -299,7 +308,7 @@ class Server extends EventEmitter {
             $this->httpResponse->setStatus($httpCode);
             $this->httpResponse->addHeaders($headers);
             $this->httpResponse->setBody($DOM->saveXML());
-            HTTP\Sapi::sendResponse($this->httpResponse);
+            $this->sapi->sendResponse($this->httpResponse);
 
         }
 
@@ -449,7 +458,7 @@ class Server extends EventEmitter {
         if (!$this->emit('afterMethod:' . $method,[$request, $response])) return;
         if (!$this->emit('afterMethod', [$request, $response])) return;
 
-        HTTP\Sapi::sendResponse($response);
+        $this->sapi->sendResponse($response);
 
     }
 
diff --git a/tests/Sabre/CalDAV/ICSExportPluginTest.php b/tests/Sabre/CalDAV/ICSExportPluginTest.php
index 9a7d015..1c81ce5 100644
--- a/tests/Sabre/CalDAV/ICSExportPluginTest.php
+++ b/tests/Sabre/CalDAV/ICSExportPluginTest.php
@@ -191,6 +191,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
         $s->addPlugin(new DAVACL\Plugin());
@@ -244,6 +245,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -279,6 +281,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -314,6 +317,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -353,6 +357,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -388,6 +393,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -427,6 +433,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -464,6 +471,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
@@ -500,6 +508,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $p = new ICSExportPlugin();
 
         $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
         $s->addPlugin($p);
         $s->addPlugin(new Plugin());
 
diff --git a/tests/Sabre/CalDAV/PluginTest.php b/tests/Sabre/CalDAV/PluginTest.php
index 50696f3..4026b3c 100644
--- a/tests/Sabre/CalDAV/PluginTest.php
+++ b/tests/Sabre/CalDAV/PluginTest.php
@@ -73,6 +73,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
 
         $objectTree = new DAV\ObjectTree($root);
         $this->server = new DAV\Server($objectTree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
         $this->server->setBaseUri('/');
         $this->plugin = new Plugin();
diff --git a/tests/Sabre/CalDAV/ValidateICalTest.php b/tests/Sabre/CalDAV/ValidateICalTest.php
index bd77aaa..683a95e 100644
--- a/tests/Sabre/CalDAV/ValidateICalTest.php
+++ b/tests/Sabre/CalDAV/ValidateICalTest.php
@@ -44,6 +44,7 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
         );
 
         $this->server = new DAV\Server($tree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
 
         $plugin = new Plugin();
diff --git a/tests/Sabre/CardDAV/AbstractPluginTest.php b/tests/Sabre/CardDAV/AbstractPluginTest.php
index 94081fc..a123099 100644
--- a/tests/Sabre/CardDAV/AbstractPluginTest.php
+++ b/tests/Sabre/CardDAV/AbstractPluginTest.php
@@ -4,6 +4,7 @@ namespace Sabre\CardDAV;
 
 use Sabre\DAV;
 use Sabre\DAVACL;
+use Sabre\HTTP;
 
 abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase {
 
@@ -33,6 +34,7 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase {
         $this->plugin = new Plugin();
         $this->plugin->directories = array('directory');
         $this->server = new DAV\Server($tree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->addPlugin($this->plugin);
         $this->server->debugExceptions = true;
 
diff --git a/tests/Sabre/CardDAV/ValidateVCardTest.php b/tests/Sabre/CardDAV/ValidateVCardTest.php
index fa91644..b2dccaf 100644
--- a/tests/Sabre/CardDAV/ValidateVCardTest.php
+++ b/tests/Sabre/CardDAV/ValidateVCardTest.php
@@ -31,6 +31,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
         );
 
         $this->server = new DAV\Server($tree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
 
         $plugin = new Plugin();
diff --git a/tests/Sabre/DAV/AbstractServer.php b/tests/Sabre/DAV/AbstractServer.php
index 3576756..9cd50bb 100644
--- a/tests/Sabre/DAV/AbstractServer.php
+++ b/tests/Sabre/DAV/AbstractServer.php
@@ -4,8 +4,6 @@ namespace Sabre\DAV;
 
 use Sabre\HTTP;
 
-require_once 'Sabre/HTTP/ResponseMock.php';
-
 abstract class AbstractServer extends \PHPUnit_Framework_TestCase {
 
     /**
@@ -23,6 +21,7 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase {
 
         $this->response = new HTTP\ResponseMock();
         $this->server = new Server($this->getRootNode());
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->httpResponse = $this->response;
         $this->server->debugExceptions = true;
         file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents');
diff --git a/tests/Sabre/DAV/Auth/PluginTest.php b/tests/Sabre/DAV/Auth/PluginTest.php
index cc814e2..31e5f2c 100644
--- a/tests/Sabre/DAV/Auth/PluginTest.php
+++ b/tests/Sabre/DAV/Auth/PluginTest.php
@@ -60,6 +60,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
         $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
 
         $fakeServer->httpRequest = $request;
+        $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $fakeServer->exec();
 
diff --git a/tests/Sabre/DAV/Issue33Test.php b/tests/Sabre/DAV/Issue33Test.php
index c02d4bf..34dc0c1 100644
--- a/tests/Sabre/DAV/Issue33Test.php
+++ b/tests/Sabre/DAV/Issue33Test.php
@@ -96,6 +96,7 @@ class Issue33Test extends \PHPUnit_Framework_TestCase {
 
         $server->httpRequest = $request;
         $server->httpResponse = $response;
+        $server->sapi = new HTTP\SapiMock();
         $server->exec();
 
         $this->assertTrue(file_exists(SABRE_TEMPDIR  . '/issue33/' . urldecode('%C3%A0fo%C3%B3')));
diff --git a/tests/Sabre/DAV/Locks/MSWordTest.php b/tests/Sabre/DAV/Locks/MSWordTest.php
index 7f078ec..792f449 100644
--- a/tests/Sabre/DAV/Locks/MSWordTest.php
+++ b/tests/Sabre/DAV/Locks/MSWordTest.php
@@ -25,6 +25,7 @@ class MSWordTest extends \PHPUnit_Framework_TestCase {
 
         $server->httpRequest = $this->getLockRequest();
         $server->httpResponse = $response1;
+        $server->sapi = new HTTP\SapiMock();
         $server->exec();
 
         $this->assertEquals(201, $server->httpResponse->status);
diff --git a/tests/Sabre/DAV/ServerCopyMoveTest.php b/tests/Sabre/DAV/ServerCopyMoveTest.php
index 9b16ff9..3e5c0db 100644
--- a/tests/Sabre/DAV/ServerCopyMoveTest.php
+++ b/tests/Sabre/DAV/ServerCopyMoveTest.php
@@ -20,6 +20,7 @@ class ServerCopyMoveTest extends \PHPUnit_Framework_TestCase {
         $dir = new FS\Directory(SABRE_TEMPDIR);
         $tree = new ObjectTree($dir);
         $this->server = new Server($tree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
         $this->server->httpResponse = $this->response;
         file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents');
diff --git a/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/tests/Sabre/DAVACL/ExpandPropertiesTest.php
index 9ee6e0d..aba88d6 100644
--- a/tests/Sabre/DAVACL/ExpandPropertiesTest.php
+++ b/tests/Sabre/DAVACL/ExpandPropertiesTest.php
@@ -29,6 +29,7 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase {
         );
 
         $fakeServer = new DAV\Server($tree);
+        $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->debugExceptions = true;
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $plugin = new Plugin();
diff --git a/tests/Sabre/DAVACL/PluginAdminTest.php b/tests/Sabre/DAVACL/PluginAdminTest.php
index f257832..f824948 100644
--- a/tests/Sabre/DAVACL/PluginAdminTest.php
+++ b/tests/Sabre/DAVACL/PluginAdminTest.php
@@ -21,6 +21,7 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase {
         );
 
         $fakeServer = new DAV\Server($tree);
+        $fakeServer->sapi = new HTTP\SapiMock();
         $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
         $fakeServer->addPlugin($plugin);
         $plugin = new Plugin();
@@ -56,6 +57,7 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase {
         );
 
         $fakeServer = new DAV\Server($tree);
+        $fakeServer->sapi = new HTTP\SapiMock();
         $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
         $fakeServer->addPlugin($plugin);
         $plugin = new Plugin();
diff --git a/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
index 1989946..bfaad94 100644
--- a/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
+++ b/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
@@ -18,6 +18,7 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase {
         $dir->addChild($principals);
 
         $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+        $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $fakeServer->debugExceptions = true;
         $plugin = new MockPlugin($backend,'realm');
diff --git a/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
index 4fb2446..96ba526 100644
--- a/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
+++ b/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
@@ -18,6 +18,7 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase {
         $dir->addChild($principals);
 
         $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+        $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $plugin = new Plugin($backend,'realm');
         $this->assertTrue($plugin instanceof Plugin);
diff --git a/tests/Sabre/DAVServerTest.php b/tests/Sabre/DAVServerTest.php
index 38c67f0..3e7cadb 100644
--- a/tests/Sabre/DAVServerTest.php
+++ b/tests/Sabre/DAVServerTest.php
@@ -11,7 +11,8 @@ require_once 'Sabre/DAV/Auth/Backend/Mock.php';
 
 use
     Sabre\HTTP\Request,
-    Sabre\HTTP\Response;
+    Sabre\HTTP\Response,
+    Sabre\HTTP\Sapi;
 
 /**
  * This class may be used as a basis for other webdav-related unittests.
@@ -83,6 +84,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
         $this->setUpTree();
 
         $this->server = new DAV\Server($this->tree);
+        $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
 
         if ($this->setupCalDAV) {
diff --git a/tests/Sabre/HTTP/ResponseMock.php b/tests/Sabre/HTTP/ResponseMock.php
index 4a98230..624d920 100644
--- a/tests/Sabre/HTTP/ResponseMock.php
+++ b/tests/Sabre/HTTP/ResponseMock.php
@@ -20,13 +20,4 @@ class ResponseMock extends Response {
     public $status;
     public $headers = [];
 
-    /**
-     * Overriding this so nothing is ever echo'd.
-     *
-     * @return void
-     */
-    public function send() {
-
-    }
-
 }
diff --git a/tests/Sabre/HTTP/ResponseMock.php b/tests/Sabre/HTTP/SapiMock.php
similarity index 71%
copy from tests/Sabre/HTTP/ResponseMock.php
copy to tests/Sabre/HTTP/SapiMock.php
index 4a98230..2e5cf31 100644
--- a/tests/Sabre/HTTP/ResponseMock.php
+++ b/tests/Sabre/HTTP/SapiMock.php
@@ -11,21 +11,14 @@ namespace Sabre\HTTP;
  * @author Evert Pot (http://evertpot.com/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-class ResponseMock extends Response {
-
-    /**
-     * Making these public.
-     */
-    public $body;
-    public $status;
-    public $headers = [];
+class SapiMock extends Sapi {
 
     /**
      * Overriding this so nothing is ever echo'd.
      *
      * @return void
      */
-    public function send() {
+    static public function sendResponse(\Sabre\HTTP\ResponseInterface $r) {
 
     }
 
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 8abd8fe..fda2be5 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -7,6 +7,7 @@ include 'Sabre/TestUtil.php';
 include 'Sabre/DAVServerTest.php';
 include 'Sabre/CardDAV/Backend/AbstractPDOTest.php';
 include 'Sabre/CardDAV/TestUtil.php';
+include 'Sabre/HTTP/SapiMock.php';
 include 'Sabre/DAV/ClientMock.php';
 
 date_default_timezone_set('UTC');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list