Author: ts
Date: Wed Sep 19 15:08:36 2007
New Revision: 6198

Log:
- Added LOCK request class + tests.
- Moved TYPE_ and SCOPE_ constants into ezcWebdavLockRequest.

Added:
    trunk/Webdav/src/request/content/lock_info.php   (with props)
    trunk/Webdav/src/request/lock.php   (with props)
    trunk/Webdav/tests/request_lock.php   (with props)
Modified:
    trunk/Webdav/design/class_diagram.png
    trunk/Webdav/design/rfc_overview.txt
    trunk/Webdav/src/properties/lockdiscovery_activelock.php
    trunk/Webdav/src/properties/supportedlock_lockentry.php
    trunk/Webdav/src/transport.php
    trunk/Webdav/src/webdav_autoload.php
    trunk/Webdav/tests/property_lockdiscovery_activelock_test.php
    trunk/Webdav/tests/property_supportedlock_lockentry_test.php

Modified: trunk/Webdav/design/class_diagram.png
==============================================================================
Binary files - no diff available.

Modified: trunk/Webdav/design/rfc_overview.txt
==============================================================================
--- trunk/Webdav/design/rfc_overview.txt [iso-8859-1] (original)
+++ trunk/Webdav/design/rfc_overview.txt [iso-8859-1] Wed Sep 19 15:08:36 2007
@@ -994,10 +994,6 @@
 Headers
 =======
 
-Lock-Token
-  Returned by a LOCK operation if a new lock was successfully created. Holds
-  the token identifying exactly this lock. It is not used on a lock refresh,
-  since the lock token is already known and used here.
 Timeout
   Allows the client to define a timeout value for the lock. This timeout is not
   mandatory for the server, since locks can also disappear by a system crash or
@@ -1008,9 +1004,53 @@
   Determines the depth of locking for a collection resource. Valid values are
   here only "0" (for only the collection itself) and "infinity". The default
   value is "infinity".
+If
+  The If-Header, which is commonly used to indicate to a server that oneself is
+  the valid owner of a lock, might be present in case of lock refresh requests
+  and gives the lock token it requests an update to.
+Authorization
+  While this header is not directly used by the WebDAV RFC it is commonly used
+  to submit various authorization informations, especially in cases of the LOCK
+  examples.
+
 
 XML
 ===
+
+<!ELEMENT lockinfo (lockscope, locktype, owner?) >
+  This element is used as a possible body of the lock request. It is used to
+  specify information about the lock to be created using <lockscop />,
+  <locktype /> and optionally <owner /> XML elements.
+<!ELEMENT lockscope (exclusive | shared) >
+  This element must always be present in the <lockinfo /> element and its
+  possible (constant) values describe the type of lock.
+<!ELEMENT locktype (write) >
+  So far the specification only describes 1 possible settings element here,
+  which is write. => Only write-locks are possible.
+<!ELEMENT owner ANY>
+  The optional owner element may contain anything as a description for the
+  owner of the lock. Possible would be e.g. a user ID or the URL of the users
+  website (see example).
+
+.. Note::
+   We asume here 1 of 2 alternatives for the <owner /> element:
+   - A <href /> element with a URL
+   - A #PCDATA node
+   Both will simply be stored as a string and need to be re-serialized
+   correctly, if a URI is returned.
+
+Example
+-------
+
+::
+
+   <D:lockinfo xmlns:D="DAV:">
+     <D:locktype><D:write/></D:locktype>
+     <D:lockscope><D:exclusive/></D:lockscope>
+     <D:owner>
+          <D:href>http://www.ics.uci.edu/~ejw/contact.html</D:href>
+     </D:owner>
+   </D:lockinfo>
 
 
 Response
@@ -1203,6 +1243,10 @@
 Headers
 =======
 
+Lock-Token
+  Uses the lock ID returned by a LOCK operation to UNLOCK the resources locked
+  by this token.
+
 XML
 ===
 

Modified: trunk/Webdav/src/properties/lockdiscovery_activelock.php
==============================================================================
--- trunk/Webdav/src/properties/lockdiscovery_activelock.php [iso-8859-1] 
(original)
+++ trunk/Webdav/src/properties/lockdiscovery_activelock.php [iso-8859-1] Wed 
Sep 19 15:08:36 2007
@@ -30,16 +30,16 @@
     /**
      * Creates a new ezcWebdavSupportedLockPropertyLockentry.
      * 
-     * @param int           $lockType  Lock type (constant self::TYPE_*).
-     * @param int           $lockScope Lock scope (constant self::SCOPE_*).
+     * @param int           $lockType  Lock type (constant 
ezcWebdavLockRequest::TYPE__*).
+     * @param int           $lockScope Lock scope (constant 
ezcWebdavLockRequest::SCOPE__*).
      * @param int           $depth     Lock depth (constant 
ezcWebdavRequest::DEPTH_*).
      * @param string        $owner
      * @param DateTime      $timeout
      * @param array(string) $tokens
      * @return void
      */
-    public function __construct( $lockType         = self::TYPE_READ,
-                                 $lockScope        = self::SCOPE_SHARED,
+    public function __construct( $lockType         = 
ezcWebdavLockRequest::TYPE__READ,
+                                 $lockScope        = 
ezcWebdavLockRequest::SCOPE__SHARED,
                                  $depth            = 
ezcWebdavRequest::DEPTH_INFINITY,
                                  $owner            = null,
                                  DateTime $timeout = null,
@@ -133,8 +133,8 @@
     {
         parent::clear();
 
-        $this->properties['lockType']  = self::TYPE_READ;
-        $this->properties['lockScope'] = self::SCOPE_SHARED;
+        $this->properties['lockType']  = ezcWebdavLockRequest::TYPE__READ;
+        $this->properties['lockScope'] = ezcWebdavLockRequest::SCOPE__SHARED;
         $this->properties['depth']     = ezcWebdavRequest::DEPTH_INFINITY;
         $this->properties['tokens']    = array();
     }

Modified: trunk/Webdav/src/properties/supportedlock_lockentry.php
==============================================================================
--- trunk/Webdav/src/properties/supportedlock_lockentry.php [iso-8859-1] 
(original)
+++ trunk/Webdav/src/properties/supportedlock_lockentry.php [iso-8859-1] Wed 
Sep 19 15:08:36 2007
@@ -20,12 +20,6 @@
  */
 class ezcWebdavSupportedLockPropertyLockentry extends ezcWebdavLiveProperty
 {
-    const TYPE_READ       = 1;
-    const TYPE_WRITE      = 2;
-                       
-    const SCOPE_SHARED    = 1;
-    const SCOPE_EXCLUSIVE = 2;
-
     /**
      * Creates a new ezcWebdavSupportedLockPropertyLockentry.
      * 
@@ -33,7 +27,7 @@
      * @param int $lockScope Lock scope (constant SCOPE_*).
      * @return void
      */
-    public function __construct( $lockType = self::TYPE_READ, $lockScope = 
self::SCOPE_SHARED )
+    public function __construct( $lockType = ezcWebdavLockRequest::TYPE__READ, 
$lockScope = ezcWebdavLockRequest::SCOPE__SHARED )
     {
         parent::__construct( 'lockentry' );
 
@@ -61,18 +55,18 @@
         switch ( $propertyName )
         {
             case 'lockType':
-                if ( $propertyValue !== self::TYPE_READ && $propertyValue !== 
self::TYPE_WRITE )
+                if ( $propertyValue !== ezcWebdavLockRequest::TYPE__READ && 
$propertyValue !== ezcWebdavLockRequest::TYPE__WRITE )
                 {
-                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcWebdavSupportedLockPropertyLockentry::TYPE_*' );
+                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcWebdavLockRequest::TYPE_*' );
                 }
 
                 $this->properties[$propertyName] = $propertyValue;
                 break;
 
             case 'lockScope':
-                if ( $propertyValue !== self::SCOPE_SHARED && $propertyValue 
!== self::SCOPE_EXCLUSIVE )
+                if ( $propertyValue !== ezcWebdavLockRequest::SCOPE__SHARED && 
$propertyValue !== ezcWebdavLockRequest::SCOPE__EXCLUSIVE )
                 {
-                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcWebdavSupportedLockPropertyLockentry::SCOPE_*' );
+                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcWebdavLockRequest::SCOPE_*' );
                 }
 
                 $this->properties[$propertyName] = $propertyValue;
@@ -107,8 +101,8 @@
     {
         parent::clear();
 
-        $this->properties['lockType']  = self::TYPE_READ;
-        $this->properties['lockScope'] = self::SCOPE_SHARED;
+        $this->properties['lockType']  = ezcWebdavLockRequest::TYPE__READ;
+        $this->properties['lockScope'] = ezcWebdavLockRequest::SCOPE__SHARED;
     }
 }
 

Added: trunk/Webdav/src/request/content/lock_info.php
==============================================================================
--- trunk/Webdav/src/request/content/lock_info.php (added)
+++ trunk/Webdav/src/request/content/lock_info.php [iso-8859-1] Wed Sep 19 
15:08:36 2007
@@ -1,0 +1,140 @@
+<?php
+
+/**
+ * Class representing the <lockinfo /> XML element in the LOCK request body.
+ * An instance of this class represents the <lockinfo /> XML element,
+ * that may optionally be contained in the body of a LOCK request.
+ * 
+ * An instance of this class must have the properties [EMAIL PROTECTED] 
$lockScope} and
+ * [EMAIL PROTECTED] $lockType} set. The property [EMAIL PROTECTED] $owner} is 
optional. 
+ * 
+ * @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
+ *
+ * @property int $lockScope Represents the <lockscope /> XML element.
+ * @property int $lockType Represents the <locktype /> XML element.
+ * @property string $owner Represents the <owner /> XML element.
+ */
+class ezcWebdavRequestLockInfoContent extends ezcWebdavXmlBase
+{
+    /**
+     * Container to hold the properties
+     *
+     * @var array(string=>mixed)
+     */
+    protected $properties = array();
+
+    /**
+     * Creates a new instance.
+     * 
+     * @return void
+     */
+    public function __construct( $lockScope, $lockType, $owner = null )
+    {
+        $this->properties['lockScope'] = null;
+        $this->properties['lockType']  = null;
+        $this->properties['owner']     = null;
+
+        $this->lockScope = $lockScope;
+        $this->lockType  = $lockType;
+        $this->owner     = $owner;
+    }
+
+    /**
+     * Sets a property.
+     * This method is called when an property is to be set.
+     * 
+     * @param string $propertyName The name of the property to set.
+     * @param mixed $propertyValue The property value.
+     * @ignore
+     *
+     * @throws ezcBasePropertyNotFoundException
+     *         if the given property does not exist.
+     * @throws ezcBaseValueException
+     *         if the value to be assigned to a property is invalid.
+     * @throws ezcBasePropertyPermissionException
+     *         if the property to be set is a read-only property.
+     */
+    public function __set( $propertyName, $propertyValue )
+    {
+        switch ( $propertyName )
+        {
+            case 'lockScope':
+                if ( $propertyValue !== ezcWebdavLockRequest::SCOPE_SHARED && 
$propertyValue !== ezcWebdavLockRequest::SCOPE_EXCLUSIVE )
+                {
+                    throw new ezcBaseValueException(
+                        $propertyName,
+                        $propertyValue,
+                        'ezcWebdavLockRequest::SCOPE_SHARED or 
ezcWebdavLockRequest::SCOPE_EXCLUSIVE'
+                    );
+                }
+                break;
+            case 'lockType':
+                if ( $propertyValue !== ezcWebdavLockRequest::TYPE_WRITE && 
$propertyValue !== ezcWebdavLockRequest::TYPE_READ )
+                {
+                    throw new ezcBaseValueException(
+                        $propertyName,
+                        $propertyValue,
+                        'ezcWebdavLockRequest::TYPE_READ or 
ezcWebdavLockRequest::TYPE_WRITE'
+                    );
+                }
+                break;
+            case 'owner':
+                if ( is_string( $propertyValue ) === false && $propertyValue 
!== null )
+                {
+                    throw new ezcBaseValueException(
+                        $propertyName,
+                        $propertyValue,
+                        'string or null'
+                    );
+                }
+                break;
+            default:
+                throw new ezcBasePropertyNotFoundException( $propertyName );
+        }
+        $this->properties[$propertyName] = $propertyValue;
+    }
+
+    /**
+     * Property get access.
+     * Simply returns a given property.
+     * 
+     * @throws ezcBasePropertyNotFoundException
+     *         If a the value for the property propertys is not an instance of
+     * @param string $propertyName The name of the property to get.
+     * @return mixed The property value.
+     *
+     * @ignore
+     *
+     * @throws ezcBasePropertyNotFoundException
+     *         if the given property does not exist.
+     * @throws ezcBasePropertyPermissionException
+     *         if the property to be set is a write-only property.
+     */
+    public function __get( $propertyName )
+    {
+        if ( $this->__isset( $propertyName ) === true )
+        {
+            return $this->properties[$propertyName];
+        }
+        throw new ezcBasePropertyNotFoundException( $propertyName );
+    }
+
+    /**
+     * Returns if a property exists.
+     * Returns true if the property exists in the [EMAIL PROTECTED] 
$properties} array
+     * (even if it is null) and false otherwise. 
+     *
+     * @param string $propertyName Option name to check for.
+     * @return void
+     * @ignore
+     */
+    public function __isset( $propertyName )
+    {
+        return array_key_exists( $propertyName, $this->properties );
+    }
+}
+
+?>

Propchange: trunk/Webdav/src/request/content/lock_info.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Webdav/src/request/lock.php
==============================================================================
--- trunk/Webdav/src/request/lock.php (added)
+++ trunk/Webdav/src/request/lock.php [iso-8859-1] Wed Sep 19 15:08:36 2007
@@ -1,0 +1,149 @@
+<?php
+/**
+ * File containing the ezcWebdavLockRequest class.
+ *
+ * @package Webdav
+ * @version //autogentag//
+ * @copyright Lockright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Request class generated by a LOCK request.
+ * This request represents the WebDAV LOCK action.
+ *
+ * An object of this class may have 1 of 3 possible properties used. If none is
+ * used, it must be asumed that the [EMAIL PROTECTED] $allProp} property is 
set to true.
+ *
+ * The [EMAIL PROTECTED] $allProp} property indicates, that a list of all 
available
+ * properties is required, including the value of each property.
+ * In contrast, the [EMAIL PROTECTED] $propName} property indicates, that only 
a list of
+ * property names, without property values, is requested. The [EMAIL 
PROTECTED] $prop}
+ * property is of type array (or null, if not set) and can contain a list of
+ * property names, which are requested to be returned, including their values.
+ *
+ * Optional headers for this request are:
+ * - Depth (default: ezcWebdavRequest::DEPTH_INFINITY)
+ * 
+ * @package Webdav
+ * @version //autogen//
+ * @copyright Lockright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @author  
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ *
+ * @property bool $allProp
+ *           Representing the <allprop /> XML element.
+ * @property bool $propName 
+ *           Representing the <propname /> XML element. 
+ * @property array(string) $prop
+ *           Representing the <prop /> XML element. Can contain a list of
+ *           property names.
+ */
+class ezcWebdavLockRequest extends ezcWebdavRequest
+{
+    /**
+     * Indicates a read lock. Not supported by RFC 2518.
+     */
+    const TYPE_READ       = 1;
+    /**
+     * Indicates a write lock. Represents the XML element <write /> inside
+     * other XML elements. 
+     */
+    const TYPE_WRITE      = 2;
+                       
+    /**
+     * Represents a shared lock. 
+     */
+    const SCOPE_SHARED    = 1;
+    /**
+     * Represents an exclusive lock. 
+     */
+    const SCOPE_EXCLUSIVE = 2;
+
+    /**
+     * Creates a new LOCK request object.
+     * Sets the defaults for the optional headers for this request. Expects the
+     * URI of the request to be encapsulated.
+     * 
+     * @param string $requestUri
+     * @return void
+     */
+    public function __construct( $requestUri )
+    {
+        // Set from constructor values
+        parent::__construct( $requestUri );
+
+        // Set header defaults
+        $this->headers['Depth']     = ezcWebdavRequest::DEPTH_INFINITY;
+        $this->headers['Timeout']   = null;
+
+        // Create properties
+        $this->properties['lockInfo']  = null;
+    }
+
+    /**
+     * Sets a property.
+     * This method is called when an property is to be set.
+     * 
+     * @param string $propertyName The name of the property to set.
+     * @param mixed $propertyValue The property value.
+     * @ignore
+     *
+     * @throws ezcBasePropertyNotFoundException
+     *         if the given property does not exist.
+     * @throws ezcBaseValueException
+     *         if the value to be assigned to a property is invalid.
+     * @throws ezcBasePropertyPermissionException
+     *         if the property to be set is a read-only property.
+     */
+    public function __set( $propertyName, $propertyValue )
+    {
+        switch ( $propertyName )
+        {
+            case 'lockInfo':
+                if ( ( $propertyValue instanceof 
ezcWebdavRequestLockInfoContent ) === false && $propertyValue !== null )
+                {
+                    throw new ezcBaseValueException( $propertyName, 
$propertyValue, 'ezcWebdavRequestLockInfoContent or null' );
+                }
+                break;
+            default:
+                parent::__set( $propertyName, $propertyValue );
+        }
+        $this->properties[$propertyName] = $propertyValue;
+    }
+
+    /**
+     * Validates the headers set in this request.
+     * This method validates that all required headers are available and that
+     * all feasible headers for this request have valid values.
+     *
+     * @return void
+     *
+     * @throws ezcWebdavMissingHeaderException
+     *         if a required header is missing.
+     * @throws ezcWebdavInvalidHeaderException
+     *         if a header is present, but its content does not validate.
+     */
+    public function validateHeaders()
+    {
+        if ( isset( $this->headers['Depth'] ) === false )
+        {
+            throw new ezcWebdavMissingHeaderException( 'Depth' );
+        }
+
+        if ( $this->headers['Depth'] !== ezcWebdavRequest::DEPTH_ZERO
+            && $this->headers['Depth'] !== ezcWebdavRequest::DEPTH_INFINITY )
+        {
+
+            throw new ezcWebdavInvalidHeaderException(
+                'Depth',
+                $this->headers['Depth'],
+                'ezcWebdavRequest::DEPTH_ZERO or 
ezcWebdavRequest::DEPTH_INFINITY'
+            );
+        }
+
+        // Validate common HTTP/WebDAV headers
+        parent::validateHeaders();
+    }
+}
+
+?>

Propchange: trunk/Webdav/src/request/lock.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Wed Sep 19 15:08:36 2007
@@ -55,6 +55,8 @@
                 return $this->parseCopyRequest( $uri, $body );
             case 'DELETE':
                 return $this->parseDeleteRequest( $uri, $body );
+            case 'LOCK':
+                return $this->parseLockRequest( $uri, $body );
             default:
                 throw new ezcWebdavInvalidRequestMethodException(
                     $_SERVER['REQUEST_METHOD']
@@ -233,6 +235,24 @@
     protected function parseDeleteRequest( $uri, $body )
     {
         return new ezcWebdavDeleteRequest( $uri );
+    }
+    
+    // LOCK
+
+    /**
+     * Parses the LOCK request and returns a request object.
+     * This method is responsible for parsing the LOCK request. It
+     * retrieves the current request URI in $uri and the request body as $body.
+     * The return value, if no exception is thrown, is a valid [EMAIL 
PROTECTED]
+     * ezcWebdavLockRequest} object.
+     * 
+     * @param string $uri 
+     * @param string $body 
+     * @return ezcWebdavLockRequest
+     */
+    protected function parseLockRequest( $uri, $body )
+    {
+        return new ezcWebdavLockRequest( $uri );
     }
 
     // PROPFIND

Modified: trunk/Webdav/src/webdav_autoload.php
==============================================================================
--- trunk/Webdav/src/webdav_autoload.php [iso-8859-1] (original)
+++ trunk/Webdav/src/webdav_autoload.php [iso-8859-1] Wed Sep 19 15:08:36 2007
@@ -55,6 +55,7 @@
     'ezcWebdavHeadResponse'                    => 'Webdav/response/head.php',
     'ezcWebdavLockDiscoveryProperty'           => 
'Webdav/properties/lockdiscovery.php',
     'ezcWebdavLockDiscoveryPropertyActiveLock' => 
'Webdav/properties/lockdiscovery_activelock.php',
+    'ezcWebdavLockRequest'                     => 'Webdav/request/lock.php',
     'ezcWebdavMakeCollectionRequest'           => 'Webdav/request/mkcol.php',
     'ezcWebdavMakeCollectionResponse'          => 'Webdav/response/mkcol.php',
     'ezcWebdavMemoryBackend'                   => 'Webdav/backend/memory.php',
@@ -71,6 +72,7 @@
     'ezcWebdavPropStatResponse'                => 
'Webdav/response/propstat.php',
     'ezcWebdavPutRequest'                      => 'Webdav/request/put.php',
     'ezcWebdavPutResponse'                     => 'Webdav/response/put.php',
+    'ezcWebdavRequestLockInfoContent'          => 
'Webdav/request/content/lock_info.php',
     'ezcWebdavRequestPropertyBehaviourContent' => 
'Webdav/request/content/property_behaviour.php',
     'ezcWebdavResource'                        => 
'Webdav/structs/resource.php',
     'ezcWebdavResourceTypeProperty'            => 
'Webdav/properties/resourcetype.php',

Modified: trunk/Webdav/tests/property_lockdiscovery_activelock_test.php
==============================================================================
--- trunk/Webdav/tests/property_lockdiscovery_activelock_test.php [iso-8859-1] 
(original)
+++ trunk/Webdav/tests/property_lockdiscovery_activelock_test.php [iso-8859-1] 
Wed Sep 19 15:08:36 2007
@@ -14,8 +14,8 @@
         $this->className = 'ezcWebdavLockDiscoveryPropertyActiveLock';
         $this->propertyName = 'activelock';
         $this->defaultValues = array(
-            'lockType'  => ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_READ,
-            'lockScope' => 
ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_SHARED,
+            'lockType'  => ezcWebdavLockRequest::TYPE_READ,
+            'lockScope' => ezcWebdavLockRequest::SCOPE_SHARED,
             'depth'     => ezcWebdavRequest::DEPTH_INFINITY,
             'owner'     => null,
             'timeout'   => null,
@@ -23,12 +23,12 @@
         );
         $this->workingValues = array(
             'lockType' => array(
-                ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_READ,
-                ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_WRITE,
+                ezcWebdavLockRequest::TYPE_READ,
+                ezcWebdavLockRequest::TYPE_WRITE,
             ),
             'lockScope' => array(
-                ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_SHARED,
-                ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_EXCLUSIVE,
+                ezcWebdavLockRequest::SCOPE_SHARED,
+                ezcWebdavLockRequest::SCOPE_EXCLUSIVE,
             ),
             'depth' => array(
                 ezcWebdavRequest::DEPTH_ZERO,

Modified: trunk/Webdav/tests/property_supportedlock_lockentry_test.php
==============================================================================
--- trunk/Webdav/tests/property_supportedlock_lockentry_test.php [iso-8859-1] 
(original)
+++ trunk/Webdav/tests/property_supportedlock_lockentry_test.php [iso-8859-1] 
Wed Sep 19 15:08:36 2007
@@ -14,17 +14,17 @@
         $this->className = 'ezcWebdavSupportedLockPropertyLockentry';
         $this->propertyName = 'lockentry';
         $this->defaultValues = array(
-            'lockType'  => ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_READ,
-            'lockScope' => 
ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_SHARED,
+            'lockType'  => ezcWebdavLockRequest::TYPE_READ,
+            'lockScope' => ezcWebdavLockRequest::SCOPE_SHARED,
         );
         $this->workingValues = array(
             'lockType' => array(
-                ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_READ,
-                ezcWebdavLockDiscoveryPropertyActiveLock::TYPE_WRITE,
+                ezcWebdavLockRequest::TYPE_READ,
+                ezcWebdavLockRequest::TYPE_WRITE,
             ),
             'lockScope' => array(
-                ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_SHARED,
-                ezcWebdavLockDiscoveryPropertyActiveLock::SCOPE_EXCLUSIVE,
+                ezcWebdavLockRequest::SCOPE_SHARED,
+                ezcWebdavLockRequest::SCOPE_EXCLUSIVE,
             ),
         );
         $this->failingValues = array(

Added: trunk/Webdav/tests/request_lock.php
==============================================================================
--- trunk/Webdav/tests/request_lock.php (added)
+++ trunk/Webdav/tests/request_lock.php [iso-8859-1] Wed Sep 19 15:08:36 2007
@@ -1,0 +1,105 @@
+<?php
+/**
+ * File containing the ezcWebdavLockRequestTest class.
+ *
+ * @package Webdav
+ * @subpackage Tests
+ * @version //autogentag//
+ * @copyright Lockright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Reqiuire base test
+ */
+require_once 'request_test.php';
+
+/**
+ * Test case for the ezcWebdavLockRequest class.
+ * 
+ * @package Webdav
+ * @subpackage Tests
+ * @version //autogentag//
+ * @copyright Lockright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+class ezcWebdavLockRequestTest extends ezcWebdavRequestTestCase
+{
+    public static function suite()
+    {
+               return new PHPUnit_Framework_TestSuite( __CLASS__ );
+    }
+
+    protected function setUp()
+    {
+        $this->className = 'ezcWebdavLockRequest';
+        $this->constructorArguments = array(
+            '/foo', '/bar'
+        );
+        $this->defaultValues = array(
+            'lockInfo'     => null,
+        );
+        $this->workingValues = array(
+            'lockInfo' => array(
+                new ezcWebdavRequestLockInfoContent( 
ezcWebdavLockRequest::SCOPE_EXCLUSIVE, ezcWebdavLockRequest::TYPE_WRITE ),
+                new ezcWebdavRequestLockInfoContent( 
ezcWebdavLockRequest::SCOPE_SHARED, ezcWebdavLockRequest::TYPE_WRITE, 'Foo Bar' 
),
+                new ezcWebdavRequestLockInfoContent( 
ezcWebdavLockRequest::SCOPE_SHARED, ezcWebdavLockRequest::TYPE_WRITE, 
'http://example.com/foo/bar' ),
+                null,
+            ),
+        );
+        $this->failingValues = array(
+            'lockInfo' => array(
+                23,
+                23.34,
+                'foo bar',
+                array( 23, 42 ),
+                new stdClass(),
+                true,
+                false,
+            ),
+        );
+    }
+
+    public function testValidateHeadersSuccess()
+    {
+        $req = new ezcWebdavLockRequest( '/foo', '/bar' );
+        $req->validateHeaders();
+
+        $req->setHeader( 'Depth', ezcWebdavRequest::DEPTH_ZERO );
+        $req->validateHeaders();
+
+        $req->setHeader( 'Depth', ezcWebdavRequest::DEPTH_INFINITY );
+        $req->validateHeaders();
+    }
+
+    public function testValidateHeadersFailure()
+    {
+        $req = new ezcWebdavLockRequest( '/foo', '/bar' );
+        
+        $req->setHeader( 'Depth', null );
+        try
+        {
+            $req->validateHeaders();
+            $this->fail( 'Exception not thrown on missing Depth header.' );
+        }
+        catch ( ezcWebdavMissingHeaderException $e ) {}
+
+        $req->setHeader( 'Depth', 'A' );
+        try
+        {
+            $req->validateHeaders();
+            $this->fail( 'Exception not thrown on invalid Depth header.' );
+        }
+        catch ( ezcWebdavInvalidHeaderException $e ) {}
+
+        $req->setHeader( 'Depth', ezcWebdavRequest::DEPTH_ONE );
+        try
+        {
+            $req->validateHeaders();
+            $this->fail( 'Exception not thrown on invalid Depth header.' );
+        }
+        catch ( ezcWebdavInvalidHeaderException $e ) {}
+    }
+}
+
+?>

Propchange: trunk/Webdav/tests/request_lock.php
------------------------------------------------------------------------------
    svn:eol-style = native


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to