Author: ts
Date: Fri Oct 19 15:09:44 2007
New Revision: 6529

Log:
- Refactored transport layer to use global server modules defined by
  ezcWebdavServerConfiguration.
- Added ezcWebdavHeaderHandler for global header handling module.
- Adjusted test cases.

Added:
    trunk/Webdav/src/transports/header_handler.php   (with props)
Modified:
    trunk/Webdav/src/responses/error.php
    trunk/Webdav/src/server.php
    trunk/Webdav/src/server_configuration.php
    trunk/Webdav/src/transport.php
    trunk/Webdav/src/transports/property_handler.php
    trunk/Webdav/tests/classes/foo_custom_classes.php
    trunk/Webdav/tests/client_test.php
    trunk/Webdav/tests/clients/litmus/113_PROPFIND/response/headers.php
    trunk/Webdav/tests/clients/litmus/120_PROPFIND/response/headers.php
    trunk/Webdav/tests/clients/litmus/128_PROPPATCH/response/headers.php
    trunk/Webdav/tests/clients/litmus/129_PROPFIND/response/headers.php
    trunk/Webdav/tests/clients/litmus/137_PROPFIND/response/headers.php
    trunk/Webdav/tests/server_configuration_test.php
    trunk/Webdav/tests/server_test.php

Modified: trunk/Webdav/src/responses/error.php
==============================================================================
--- trunk/Webdav/src/responses/error.php [iso-8859-1] (original)
+++ trunk/Webdav/src/responses/error.php [iso-8859-1] Fri Oct 19 15:09:44 2007
@@ -71,7 +71,10 @@
                 $this->properties[$propertyName] = $propertyValue;
                 break;
             case 'responseDescription':
-               $this->setHeader( 'Warning', 'eZComponents ' . 
$this->responseDescription );
+               if ( $this->responseDescription !== null )
+               {
+                    $this->setHeader( 'Warning', 'eZComponents error "' . 
$this->responseDescription . '"' );
+               }
                parent::__set( $propertyName, $propertyValue );
                break;
             default:

Modified: trunk/Webdav/src/server.php
==============================================================================
--- trunk/Webdav/src/server.php [iso-8859-1] (original)
+++ trunk/Webdav/src/server.php [iso-8859-1] Fri Oct 19 15:09:44 2007
@@ -149,11 +149,18 @@
      * @param ezcWebdavTransport $transport
      * @return void
      */
-    public function init( ezcWebdavPathFactory $pathFactory, ezcWebdavXmlTool 
$xmlTool, ezcWebdavPropertyHandler $propertyHandler, ezcWebdavTransport 
$transport )
+    public function init(
+        ezcWebdavPathFactory $pathFactory,
+        ezcWebdavXmlTool $xmlTool,
+        ezcWebdavPropertyHandler $propertyHandler,
+        ezcWebdavHeaderHandler $headerHandler,
+        ezcWebdavTransport $transport
+    )
     {
         $this->properties['pathFactory']     = $pathFactory;
         $this->properties['xmlTool']         = $xmlTool;
         $this->properties['propertyHandler'] = $propertyHandler;
+        $this->properties['headerHandler']   = $headerHandler;
         $this->properties['transport']       = $transport;
     }
 
@@ -175,6 +182,7 @@
         $this->properties['pathFactory']     = null;
         $this->properties['xmlTool']         = null;
         $this->properties['propertyHandler'] = null;
+        $this->properties['headerHandler']   = null;
     }
 
     /**
@@ -212,6 +220,7 @@
             case 'pathFactory':
             case 'xmlTool':
             case 'propertyHandler':
+            case 'headerHandler':
             case 'transport':
                 throw new ezcBasePropertyPermissionException( $propertyName, 
ezcBasePropertyPermissionException::READ );
 

Modified: trunk/Webdav/src/server_configuration.php
==============================================================================
--- trunk/Webdav/src/server_configuration.php [iso-8859-1] (original)
+++ trunk/Webdav/src/server_configuration.php [iso-8859-1] Fri Oct 19 15:09:44 
2007
@@ -101,6 +101,7 @@
         $transportClass                   = 'ezcWebdavTransport',
         $xmlToolClass                     = 'ezcWebdavXmlTool',
         $propertyHandlerClass             = 'ezcWebdavPropertyHandler',
+        $headerHandlerClass               = 'ezcWebdavHeaderHandler',
         ezcWebdavPathFactory $pathFactory = null
     )
     {
@@ -108,12 +109,14 @@
         $this->properties['transportClass']       = null;
         $this->properties['xmlToolClass']         = null;
         $this->properties['propertyHandlerClass'] = null;
+        $this->properties['headerHandlerClass']   = null;
         $this->properties['pathFactory']          = null;
 
         $this->userAgentRegex       = $userAgentRegex;
         $this->transportClass       = $transportClass;
         $this->xmlToolClass         = $xmlToolClass;
         $this->propertyHandlerClass = $propertyHandlerClass;
+        $this->headerHandlerClass   = $headerHandlerClass;
         $this->pathFactory          = ( $pathFactory === null ? new 
ezcWebdavAutomaticPathFactory() : $pathFactory );
     }
 
@@ -134,11 +137,12 @@
         $this->checkClasses();
 
         $xmlTool         = new $this->xmlToolClass();
-        $propertyHandler = new $this->propertyHandlerClass( $xmlTool );
+        $propertyHandler = new $this->propertyHandlerClass();
+        $headerHandler   = new $this->headerHandlerClass();
+        $transport       = new $this->transportClass();
         $pathFactory     = $this->pathFactory;
-        $transport       = new $this->transportClass( $xmlTool, 
$propertyHandler, $pathFactory );
-
-        $server->init( $pathFactory, $xmlTool, $propertyHandler, $transport );
+
+        $server->init( $pathFactory, $xmlTool, $propertyHandler, 
$headerHandler, $transport );
     }
 
     /**
@@ -176,6 +180,9 @@
 
             case ( $this->propertyHandlerClass !== 'ezcWebdavPropertyHandler' 
&& !is_subclass_of( $this->propertyHandlerClass, 'ezcWebdavPropertyHandler' ) ):
                 throw new ezcBaseValueException( 'propertyHandlerClass', 
$this->propertyHandlerClass, 'ezcWebdavPropertyHandler or derived' );
+
+            case ( $this->headerHandlerClass !== 'ezcWebdavHeaderHandler' && 
!is_subclass_of( $this->headerHandlerClass, 'ezcWebdavHeaderHandler' ) ):
+                throw new ezcBaseValueException( 'headerHandlerClass', 
$this->headerHandlerClass, 'ezcWebdavHeaderHandler or derived' );
         }
     }
 
@@ -198,6 +205,7 @@
             case 'transportClass':
             case 'xmlToolClass':
             case 'propertyHandlerClass':
+            case 'headerHandlerClass':
                 if ( !is_string( $propertyValue ) || strlen( $propertyValue ) 
< 1 )
                 {
                     throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'string, length > 0' );

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Fri Oct 19 15:09:44 2007
@@ -88,22 +88,6 @@
     const VERSION = '//autogentag//';
 
     /**
-     * Map of regular header names to $_SERVER keys.
-     *
-     * @var array(string=>string)
-     */
-    static protected $headerMap = array(
-        'Content-Length' => 'HTTP_CONTENT_LENGTH',
-        'Content-Type'   => 'CONTENT_TYPE',
-        'Depth'          => 'HTTP_DEPTH',
-        'Destination'    => 'HTTP_DESTINATION',
-        'Lock-Token'     => 'HTTP_LOCK_TOKEN',
-        'Overwrite'      => 'HTTP_OVERWRITE',
-        'Timeout'        => 'HTTP_TIMEOUT',
-        'Server'         => 'SERVER_SOFTWARE',
-    );
-
-    /**
      * Map of HTTP methods to object method names for parsing.
      *
      * Need public access here to retrieve this in [EMAIL PROTECTED]
@@ -252,11 +236,11 @@
     {
         // Set the Server header with information about eZ Components version
         // and transport implementation.
-        $serverSoftwareHeaders = $this->parseHeaders( array( 'Server' ) );
+        $headers = 
ezcWebdavServer::getInstance()->headerHandler->parseHeaders( array( 'Server' ) 
);
 
         $response->setHeader(
             'Server',
-            ( count( $serverSoftwareHeaders ) > 0 ? 
$serverSoftwareHeaders['Server'] . '/' : '' )
+            ( isset( $headers['Server'] ) && strlen( $headers['Server'] ) > 0 
? $headers['Server'] . '/' : '' )
                 . 'eZComponents/'
                 . ( self::VERSION === '//autogentag//' ? 'dev' : self::VERSION 
)
                 . '/'
@@ -492,7 +476,7 @@
             }
             if ( isset( $_SERVER[self::$headerMap[$headerName]] ) )
             {
-                $resultHeaders[$headerName] = $this->parseHeader( $headerName, 
$_SERVER[self::$headerMap[$headerName]] );
+                $resultHeaders[$headerName] = 
ezcWebdavServer::getInstance()->headerHandler->parseHeader( $headerName );
             }
         }
         return $resultHeaders;
@@ -586,7 +570,7 @@
     {
         $req = new ezcWebdavPutRequest( $path, $body );
         $req->setHeaders(
-            $this->parseHeaders(
+            ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
                 array(
                     'Content-Length', 'Content-Type'
                 )
@@ -638,7 +622,7 @@
      */
     protected function parseCopyRequest( $path, $body )
     {
-        $headers = $this->parseHeaders(
+        $headers = ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
             array( 'Destination', 'Depth', 'Overwrite' )
         );
 
@@ -689,7 +673,7 @@
      */
     protected function parseMoveRequest( $path, $body )
     {
-        $headers = $this->parseHeaders(
+        $headers = ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
             array( 'Destination', 'Depth', 'Overwrite' )
         );
 
@@ -819,7 +803,7 @@
         $request = new ezcWebdavLockRequest( $path );
 
         $request->setHeaders(
-            $this->parseHeaders(
+            ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
                 array( 'Depth', 'Timeout' )
             )
         );
@@ -903,7 +887,7 @@
         $request = new ezcWebdavUnlockRequest( $path );
 
         $request->setHeaders(
-            $this->parseHeaders(
+            ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
                 array( 'Lock-Token' )
             )
         );
@@ -974,7 +958,7 @@
         $request = new ezcWebdavPropFindRequest( $path );
 
         $request->setHeaders(
-            $this->parseHeaders(
+            ezcWebdavServer::getInstance()->headerHandler->parseHeaders(
                 array( 'Depth' )
             )
         );

Added: trunk/Webdav/src/transports/header_handler.php
==============================================================================
--- trunk/Webdav/src/transports/header_handler.php (added)
+++ trunk/Webdav/src/transports/header_handler.php [iso-8859-1] Fri Oct 19 
15:09:44 2007
@@ -1,0 +1,137 @@
+<?php
+/**
+ * File containing the ezcWebdavHeaderHandler class.
+ *
+ * @package Webdav
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * An instance of this class manages header parsing and handling.
+ *
+ * An object of this class takes care about headers in the [EMAIL PROTECTED]
+ * ezcWebdavTransport} to parse incoming headers and serialize outgoing
+ * headers.  Like for the [EMAIL PROTECTED] ezcWebdavPropertyHandler}, the 
instance of
+ * this class that is used in the current transport layer must be accessable
+ * for plugins.
+ *
+ * @package Webdav
+ * @version //autogen//
+ */
+class ezcWebdavHeaderHandler
+{
+    /**
+     * Map of regular header names to $_SERVER keys.
+     *
+     * @var array(string=>string)
+     */
+    protected $headerMap = array(
+        'Content-Length' => 'HTTP_CONTENT_LENGTH',
+        'Content-Type'   => 'CONTENT_TYPE',
+        'Depth'          => 'HTTP_DEPTH',
+        'Destination'    => 'HTTP_DESTINATION',
+        'Lock-Token'     => 'HTTP_LOCK_TOKEN',
+        'Overwrite'      => 'HTTP_OVERWRITE',
+        'Timeout'        => 'HTTP_TIMEOUT',
+        'Server'         => 'SERVER_SOFTWARE',
+    );
+
+    /**
+     * Pathfactory to process incoming headers.
+     * 
+     * @var ezcWebdavPathFactory
+     */
+    protected $pathFactory;
+
+    /**
+     * Returns an array with the given headers.
+     *
+     * Checks for the availability of headers in $headerNamess, given as an
+     * array of header names, and parses them according to their format. 
+     *
+     * The returned array can be used with [EMAIL PROTECTED] 
ezcWebdavRequest->setHeaders()}.
+     * 
+     * @param array(string) $headerNames 
+     * @return array(string=>mixed)
+     *
+     * @throws ezcWebdavUnknownHeaderException
+     *         if a header requested in $headerNames is not known in [EMAIL 
PROTECTED]
+     *         $headerNames}.
+     */
+    public function parseHeaders( array $headerNames )
+    {
+        $resultHeaders = array();
+        foreach ( $headerNames as $headerName )
+        {
+            if ( ( $value = $this->parseHeader( $headerName ) ) !== null )
+            {
+                $resultHeaders[$headerName] = $value;
+            }
+        }
+        return $resultHeaders;
+    }
+
+    /**
+     * Parses a single header.
+     *
+     * Retrieves a $headerName and returns the processed value for it, if it
+     * does exist. If the requested header is unknown, a [EMAIL PROTECTED]
+     * ezcWebdavUnknownHeaderException} is thrown. If the requested header is
+     * not present in [EMAIL PROTECTED] $_SERVER} null is returned.
+     * 
+     * @param string $headerName 
+     * @return mixed
+     */
+    public function parseHeader( $headerName )
+    {
+        if ( isset( $this->headerMap[$headerName] ) === false )
+        {
+            throw new ezcWebdavUnknownHeaderException( $headerName );
+        }
+        return ( isset( $_SERVER[$this->headerMap[$headerName]] )
+            ? $this->processHeader( $headerName, 
$_SERVER[$this->headerMap[$headerName]] )
+            : null
+        );
+    }
+
+    /**
+     * Processes a single header value.
+     *
+     * Takes the $headerName and $value of a header and parses the value 
accordingly,
+     * if necessary. Returns the parsed or unmanipuled result.
+     * 
+     * @param string $headerName 
+     * @param string $value 
+     * @return mixed
+     */
+    protected function processHeader( $headerName, $value )
+    {
+        switch ( $headerName )
+        {
+            case 'Depth':
+                switch ( trim( $value ) )
+                {
+                    case '0':
+                        $value = ezcWebdavRequest::DEPTH_ZERO;
+                        break;
+                    case '1':
+                        $value = ezcWebdavRequest::DEPTH_ONE;
+                        break;
+                    case 'infinity':
+                        $value = ezcWebdavRequest::DEPTH_INFINITY;
+                        break;
+                    // No default. Header stays as is, if not matched
+                }
+                break;
+            case 'Destination':
+                $value = 
ezcWebdavServer::getInstance()->pathFactory->parseUriToPath( $value );
+                break;
+            default:
+                // @TODO Add plugin hook
+        }
+        return $value;
+    }
+}
+
+?>

Propchange: trunk/Webdav/src/transports/header_handler.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/Webdav/src/transports/property_handler.php
==============================================================================
--- trunk/Webdav/src/transports/property_handler.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transports/property_handler.php [iso-8859-1] Fri Oct 19 
15:09:44 2007
@@ -20,7 +20,7 @@
      * 
      * @var ezcWebdavXmlTool
      */
-    protected $xml;
+    protected $xmlTool;
 
     /**
      * Regedx to parse the <getcontenttype /> XML elemens content.
@@ -41,7 +41,19 @@
      */
     public function __construct( ezcWebdavXmlTool $xml = null )
     {
-        $this->xml = ( $xml === null ? ezcWebdavServer::getInstance()->xmlTool 
: $xml );
+        if ( $xml !== null )
+        {
+            $this->xmlTool = $xml;
+        }
+    }
+
+    protected function getXmlTool()
+    {
+        if ( $this->xmlTool === null )
+        {
+            return ezcWebdavServer::getInstance()->xmlTool;
+        }
+        return $this->xmlTool;
     }
 
     /**
@@ -402,10 +414,10 @@
      */
     protected function serializeDeadProperty( ezcWebdavDeadProperty $property, 
DOMElement $parentElement )
     {
-        if ( $property->content === null || ( $contentDom = 
$this->xml->createDomDocument( $property->content ) ) === false )
+        if ( $property->content === null || ( $contentDom = 
$this->getXmlTool()->createDomDocument( $property->content ) ) === false )
         {
             return $parentElement->appendChild(
-                $this->xml->createDomElement(
+                $this->getXmlTool()->createDomElement(
                     $parentElement->ownerDocument,
                     $property->name,
                     $property->namespace
@@ -466,7 +478,7 @@
                 break;
             case 'ezcWebdavResourceTypeProperty':
                 $elementName  = 'resourcetype';
-                $elementValue = ( $property->type === 
ezcWebdavResourceTypeProperty::TYPE_COLLECTION ? array( 
$this->xml->createDomElement( $parentElement->ownerDocument, 'collection' ) ) : 
null );
+                $elementValue = ( $property->type === 
ezcWebdavResourceTypeProperty::TYPE_COLLECTION ? array( 
$this->getXmlTool()->createDomElement( $parentElement->ownerDocument, 
'collection' ) ) : null );
                 break;
             case 'ezcWebdavSourceProperty':
                 $elementName  = 'source';
@@ -479,7 +491,7 @@
         }
 
         $propertyElement = $parentElement->appendChild( 
-            $this->xml->createDomElement( $parentElement->ownerDocument, 
$elementName, $property->namespace )
+            $this->getXmlTool()->createDomElement( 
$parentElement->ownerDocument, $elementName, $property->namespace )
         );
 
         if ( $elementValue instanceof DOMDocument )
@@ -515,22 +527,22 @@
         $activeLockElements = array();
         foreach ( $activeLocks as $activeLock )
         {
-            $activeLockElement = $this->xml->createDomElement( $dom, 
'activelock' );
+            $activeLockElement = $this->getXmlTool()->createDomElement( $dom, 
'activelock' );
             
             $activeLockElement->appendChild(
-                $this->xml->createDomElement( $dom, 'locktype' )
+                $this->getXmlTool()->createDomElement( $dom, 'locktype' )
             )->appendChild(
-                $this->xml->createDomElement( $dom, ( $activeLock->lockType 
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
+                $this->getXmlTool()->createDomElement( $dom, ( 
$activeLock->lockType === ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
             );
             
             $activeLockElement->appendChild(
-                $this->xml->createDomElement( $dom, 'lockscope' )
+                $this->getXmlTool()->createDomElement( $dom, 'lockscope' )
             )->appendChild(
-                $this->xml->createDomElement( $dom, ( $activeLock->lockScope 
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
+                $this->getXmlTool()->createDomElement( $dom, ( 
$activeLock->lockScope === ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' 
: 'shared' ) )
             );
             
             $depthElement = $activeLockElement->appendChild(
-                $this->xml->createDomElement( $dom, 'depth' )
+                $this->getXmlTool()->createDomElement( $dom, 'depth' )
             );
             
             switch ( $activeLock->depth )
@@ -549,20 +561,20 @@
             if ( $activeLock->owner !== null )
             {
                 $activeLockElement->appendChild(
-                    $this->xml->createDomElement( $dom, 'owner' )
+                    $this->getXmlTool()->createDomElement( $dom, 'owner' )
                 )->nodeValue = $activeLock->owner;
             }
 
             $activeLockElement->appendChild(
-                $this->xml->createDomElement( $dom, 'timeout' )
+                $this->getXmlTool()->createDomElement( $dom, 'timeout' )
             )->$activeLock->timeout;
 
             foreach ( $activeLock->tokens as $token )
             {
                 $activeLockElement->appendChild(
-                    $this->xml->createDomElement( $dom, 'locktoken' )
+                    $this->getXmlTool()->createDomElement( $dom, 'locktoken' )
                 )->appendChild(
-                    $this->xml->createDomElement( $dom, 'href' )
+                    $this->getXmlTool()->createDomElement( $dom, 'href' )
                 )->nodeValue = $token;
             }
 
@@ -585,16 +597,16 @@
 
         foreach( $lockEntries as $lockEntry )
         {
-            $lockEntryElement = $this->xml->createDomElement( $dom, 
'lockentry' );
+            $lockEntryElement = $this->getXmlTool()->createDomElement( $dom, 
'lockentry' );
             $lockEntryElement->appendChild(
-                $this->xml->createDomElement( $dom, 'lockscope' )
+                $this->getXmlTool()->createDomElement( $dom, 'lockscope' )
             )->appendChild(
-                $this->xml->createDomElement( $dom, ( $lockEntry->lockScope 
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
+                $this->getXmlTool()->createDomElement( $dom, ( 
$lockEntry->lockScope === ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 
'shared' ) )
             );
             $lockEntryElement->appendChild(
-                $this->xml->createDomElement( $dom, 'locktype' )
+                $this->getXmlTool()->createDomElement( $dom, 'locktype' )
             )->appendChild(
-                $this->xml->createDomElement( $dom, ( $lockEntry->lockScope 
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
+                $this->getXmlTool()->createDomElement( $dom, ( 
$lockEntry->lockScope === ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
             );
             $lockEntryContentElements[] = $lockEntryElement;
         }
@@ -615,12 +627,12 @@
 
         foreach( $links as $link )
         {
-            $linkElement = $this->xml->createDomElement( $dom, 'link' );
+            $linkElement = $this->getXmlTool()->createDomElement( $dom, 'link' 
);
             $linkElement->appendChild(
-                $this->xml->createDomElement( $dom, 'src' )
+                $this->getXmlTool()->createDomElement( $dom, 'src' )
             )->nodeValue = $link->src;
             $linkElement->appendChild(
-                $this->xml->createDomElement( $dom, 'dst' )
+                $this->getXmlTool()->createDomElement( $dom, 'dst' )
             )->nodeValue = $link->dst;
             $linkContentElements[] = $linkElement;
         }

Modified: trunk/Webdav/tests/classes/foo_custom_classes.php
==============================================================================
--- trunk/Webdav/tests/classes/foo_custom_classes.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/classes/foo_custom_classes.php [iso-8859-1] Fri Oct 19 
15:09:44 2007
@@ -12,4 +12,8 @@
 {
 }
 
+class fooCustomHeaderHandler extends ezcWebdavHeaderHandler
+{
+}
+
 ?>

Modified: trunk/Webdav/tests/client_test.php
==============================================================================
--- trunk/Webdav/tests/client_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/client_test.php [iso-8859-1] Fri Oct 19 15:09:44 2007
@@ -126,21 +126,13 @@
         unset( $GLOBALS['EZC_WEBDAV_TRANSPORT_TEST_RESPONSE_STATUS'] );
 
         $this->assertEquals(
-            $response['body'],
-            $responseBody,
-            'Body sent by WebDAV server incorrect.'
-        );
-
-        $this->assertEquals(
-            $response['headers'],
-            $responseHeaders,
-            'Headers sent by WebDAV server incorrect.'
-        );
-
-        $this->assertEquals(
-            $response['status'],
-            $responseStatus,
-            'Status code sent by WebDAV server incoreect.'
+            $response,
+            array(
+                'headers' => $responseHeaders,
+                'body' => $responseBody,
+                'status' => $responseStatus,
+            ),
+            'Response sent by WebDAV server incorrect.'
         );
     }
 

Modified: trunk/Webdav/tests/clients/litmus/113_PROPFIND/response/headers.php
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/clients/litmus/120_PROPFIND/response/headers.php
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/clients/litmus/128_PROPPATCH/response/headers.php
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/clients/litmus/129_PROPFIND/response/headers.php
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/clients/litmus/137_PROPFIND/response/headers.php
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/tests/server_configuration_test.php
==============================================================================
--- trunk/Webdav/tests/server_configuration_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/server_configuration_test.php [iso-8859-1] Fri Oct 19 
15:09:44 2007
@@ -38,11 +38,12 @@
 
         $this->assertAttributeEquals(
             array(
-                'userAgentRegex'  => '(.*)',
+                'userAgentRegex'       => '(.*)',
                 'transportClass'       => 'ezcWebdavTransport',
                 'xmlToolClass'         => 'ezcWebdavXmlTool',
                 'propertyHandlerClass' => 'ezcWebdavPropertyHandler',
-                'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+                'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
             ),
             'properties',
             $cfg,
@@ -55,11 +56,12 @@
 
         $this->assertAttributeEquals(
             array(
-                'userAgentRegex'  => '(.*Nautilus.*)',
+                'userAgentRegex'       => '(.*Nautilus.*)',
                 'transportClass'       => 'ezcWebdavTransport',
                 'xmlToolClass'         => 'ezcWebdavXmlTool',
                 'propertyHandlerClass' => 'ezcWebdavPropertyHandler',
-                'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+                'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
             ),
             'properties',
             $cfg,
@@ -73,11 +75,12 @@
 
         $this->assertAttributeEquals(
             array(
-                'userAgentRegex'  => '(.*Nautilus.*)',
+                'userAgentRegex'       => '(.*Nautilus.*)',
                 'transportClass'       => 'ezcWebdavCustomTransport',
                 'xmlToolClass'         => 'ezcWebdavXmlTool',
                 'propertyHandlerClass' => 'ezcWebdavPropertyHandler',
-                'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+                'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
             ),
             'properties',
             $cfg,
@@ -92,11 +95,12 @@
 
         $this->assertAttributeEquals(
             array(
-                'userAgentRegex'  => '(.*Nautilus.*)',
+                'userAgentRegex'       => '(.*Nautilus.*)',
                 'transportClass'       => 'fooCustomTransport',
                 'xmlToolClass'         => 'fooCustomXmlTool',
                 'propertyHandlerClass' => 'ezcWebdavPropertyHandler',
-                'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+                'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
             ),
             'properties',
             $cfg,
@@ -112,11 +116,12 @@
 
         $this->assertAttributeEquals(
             array(
-                'userAgentRegex'  => '(.*Nautilus.*)',
+                'userAgentRegex'       => '(.*Nautilus.*)',
                 'transportClass'       => 'fooCustomTransport',
                 'xmlToolClass'         => 'fooCustomXmlTool',
                 'propertyHandlerClass' => 'fooCustomPropertyHandler',
-                'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+                'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
             ),
             'properties',
             $cfg,
@@ -128,16 +133,40 @@
             'fooCustomTransport',
             'fooCustomXmlTool',
             'fooCustomPropertyHandler',
-            new ezcWebdavBasicPathFactory()
-        );
-
-        $this->assertAttributeEquals(
-            array(
-                'userAgentRegex'  => '(.*Nautilus.*)',
+            'fooCustomHeaderHandler'
+        );
+
+        $this->assertAttributeEquals(
+            array(
+                'userAgentRegex'       => '(.*Nautilus.*)',
                 'transportClass'       => 'fooCustomTransport',
                 'xmlToolClass'         => 'fooCustomXmlTool',
                 'propertyHandlerClass' => 'fooCustomPropertyHandler',
-                'pathFactory'     => new ezcWebdavBasicPathFactory(),
+                'headerHandlerClass'   => 'fooCustomHeaderHandler',
+                'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
+            ),
+            'properties',
+            $cfg,
+            'Default properties not created correctly on empty ctor.'
+        );
+        
+        $cfg = new ezcWebdavServerConfiguration(
+            '(.*Nautilus.*)',
+            'fooCustomTransport',
+            'fooCustomXmlTool',
+            'fooCustomPropertyHandler',
+            'fooCustomHeaderHandler',
+            new ezcWebdavBasicPathFactory()
+        );
+
+        $this->assertAttributeEquals(
+            array(
+                'userAgentRegex'       => '(.*Nautilus.*)',
+                'transportClass'       => 'fooCustomTransport',
+                'xmlToolClass'         => 'fooCustomXmlTool',
+                'propertyHandlerClass' => 'fooCustomPropertyHandler',
+                'headerHandlerClass'   => 'fooCustomHeaderHandler',
+                'pathFactory'          => new ezcWebdavBasicPathFactory(),
             ),
             'properties',
             $cfg,
@@ -163,6 +192,7 @@
             $typicalValid, // transportClass
             $typicalValid, // xmlToolClass
             $typicalValid, // propertyHandlerClass
+            $typicalValid, // headerHandlerClass
             new ezcWebdavAutomaticPathFactory(), // pathFactory
         );
 
@@ -171,6 +201,7 @@
             $typicalFails, // transportClass
             $typicalFails, // xmlToolClass
             $typicalFails, // propertyHandlerClass
+            $typicalFails, // headerHandlerClass
             array_merge( $typicalFails, array( 'foo' ) ), // pathFactory
         );
 
@@ -184,7 +215,7 @@
             foreach ( $paramSet as $param )
             {
                 $params[$id] = $param;
-                $this->assertCtorFailure( $params, ( $i !== 4 ? 
'ezcBaseValueException' : 'PHPUnit_Framework_Error' ) );
+                $this->assertCtorFailure( $params, ( $i !== 5 ? 
'ezcBaseValueException' : 'PHPUnit_Framework_Error' ) );
             }
         }
     }
@@ -194,11 +225,12 @@
         $cfg = new ezcWebdavServerConfiguration();
 
         $defaults = array(
-            'userAgentRegex'  => '(.*)',
+            'userAgentRegex'       => '(.*)',
             'transportClass'       => 'ezcWebdavTransport',
             'xmlToolClass'         => 'ezcWebdavXmlTool',
             'propertyHandlerClass' => 'ezcWebdavPropertyHandler',
-            'pathFactory'     => new ezcWebdavAutomaticPathFactory(),
+            'headerHandlerClass'   => 'ezcWebdavHeaderHandler',
+            'pathFactory'          => new ezcWebdavAutomaticPathFactory(),
         );
 
         foreach ( $defaults as $property => $value )
@@ -218,15 +250,17 @@
             'fooCustomTransport',
             'fooCustomXmlTool',
             'fooCustomPropertyHandler',
+            'fooCustomHeaderHandler',
             new ezcWebdavBasicPathFactory()
         );
 
         $values = array(
-            'userAgentRegex'  => '(.*Nautilus.*)',
+            'userAgentRegex'       => '(.*Nautilus.*)',
             'transportClass'       => 'fooCustomTransport',
             'xmlToolClass'         => 'fooCustomXmlTool',
             'propertyHandlerClass' => 'fooCustomPropertyHandler',
-            'pathFactory'     => new ezcWebdavBasicPathFactory(),
+            'headerHandlerClass'   => 'fooCustomHeaderHandler',
+            'pathFactory'          => new ezcWebdavBasicPathFactory(),
         );
 
         foreach ( $values as $property => $value )
@@ -259,11 +293,12 @@
         $cfg = new ezcWebdavServerConfiguration();
 
         $values = array(
-            'userAgentRegex'  => '(.*Nautilus.*)',
+            'userAgentRegex'       => '(.*Nautilus.*)',
             'transportClass'       => 'fooCustomTransport',
             'xmlToolClass'         => 'fooCustomXmlTool',
             'propertyHandlerClass' => 'fooCustomPropertyHandler',
-            'pathFactory'     => new ezcWebdavBasicPathFactory(),
+            'headerHandlerClass'   => 'fooCustomHeaderHandler',
+            'pathFactory'          => new ezcWebdavBasicPathFactory(),
         );
 
         foreach( $values as $property => $value )
@@ -299,11 +334,12 @@
         );
 
         $invalidValues = array(
-            'userAgentRegex'  => $typicalFails, 
+            'userAgentRegex'       => $typicalFails, 
             'transportClass'       => $typicalFails, 
             'xmlToolClass'         => $typicalFails, 
             'propertyHandlerClass' => $typicalFails, 
-            'pathFactory'     => array_merge( $typicalFails, array( 'foo' ) ), 
+            'headerHandlerClass'   => $typicalFails,
+            'pathFactory'          => array_merge( $typicalFails, array( 'foo' 
) ), 
         );
 
         foreach ( $invalidValues as $propertyName => $propertyValues )
@@ -329,6 +365,7 @@
             'transportClass', 
             'xmlToolClass', 
             'propertyHandlerClass', 
+            'headerHandlerClass',
             'pathFactory', 
         );
 
@@ -348,6 +385,7 @@
             'fooCustomTransport',
             'fooCustomXmlTool',
             'fooCustomPropertyHandler',
+            'fooCustomHeaderHandler',
             new ezcWebdavBasicPathFactory()
         );
 
@@ -356,6 +394,7 @@
             'transportClass', 
             'xmlToolClass', 
             'propertyHandlerClass', 
+            'headerHandlerClass', 
             'pathFactory', 
         );
 
@@ -391,8 +430,8 @@
 
         $pathFactory     = new ezcWebdavAutomaticPathFactory();
         $xmlTool         = new ezcWebdavXmlTool();
-        $propertyHandler = new ezcWebdavPropertyHandler( $xmlTool );
-        $transport       = new ezcWebdavTransport( $xmlTool, $propertyHandler, 
$pathFactory );
+        $propertyHandler = new ezcWebdavPropertyHandler();
+        $transport       = new ezcWebdavTransport();
 
         $this->assertEquals(
             $xmlTool,
@@ -419,6 +458,7 @@
             'fooCustomTransport',
             'fooCustomXmlTool',
             'fooCustomPropertyHandler',
+            'fooCustomHeaderHandler',
             new ezcWebdavBasicPathFactory( 'http://foo.example.com/webdav/' )
         );
         
@@ -427,8 +467,9 @@
 
         $xmlTool         = new fooCustomXmlTool();
         $pathFactory     = new ezcWebdavBasicPathFactory( 
'http://foo.example.com/webdav/' );
-        $propertyHandler = new fooCustomPropertyHandler( $xmlTool );
-        $transport       = new fooCustomTransport( $xmlTool, $propertyHandler, 
$pathFactory );
+        $propertyHandler = new fooCustomPropertyHandler();
+        $headerHandler   = new fooCustomHeaderHandler();
+        $transport       = new fooCustomTransport();
 
         $this->assertEquals(
             $xmlTool,

Modified: trunk/Webdav/tests/server_test.php
==============================================================================
--- trunk/Webdav/tests/server_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/server_test.php [iso-8859-1] Fri Oct 19 15:09:44 2007
@@ -52,6 +52,7 @@
                 'pluginRegistry'  => new ezcWebdavPluginRegistry(),
                 'xmlTool'         => null,
                 'propertyHandler' => null,
+                'headerHandler'   => null,
                 'pathFactory'     => null,
             ),
             'properties',
@@ -70,6 +71,7 @@
             'pluginRegistry'  => new ezcWebdavPluginRegistry(),
             'xmlTool'         => null,
             'propertyHandler' => null,
+            'headerHandler'   => null,
             'pathFactory'     => null,
         );
 
@@ -112,6 +114,7 @@
             'pluginRegistry'  => new ezcWebdavPluginRegistry(),
             'xmlTool'         => null,
             'propertyHandler' => null,
+            'headerHandler'   => null,
             'pathFactory'     => null,
             'transport'       => null,
         );


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to