Author: ts
Date: Tue Sep 25 15:46:43 2007
New Revision: 6268

Log:
- Refactored Resource-Type property.
- Corrected date formats generated for date related properties.
- Added Resource-Type property to be faked by memory backend.

Modified:
    trunk/Webdav/src/backend/memory.php
    trunk/Webdav/src/properties/getcontentlength.php
    trunk/Webdav/src/properties/resourcetype.php
    trunk/Webdav/src/response/get_collection.php
    trunk/Webdav/src/transport.php
    trunk/Webdav/tests/backend_memory_test.php
    trunk/Webdav/tests/client_test_rfc_backend.php
    trunk/Webdav/tests/clients/rfc/get_collection/response/result.ser
    trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser
    trunk/Webdav/tests/property_resourcetype_test.php

Modified: trunk/Webdav/src/backend/memory.php
==============================================================================
--- trunk/Webdav/src/backend/memory.php [iso-8859-1] (original)
+++ trunk/Webdav/src/backend/memory.php [iso-8859-1] Tue Sep 25 15:46:43 2007
@@ -192,6 +192,12 @@
                         (string) strlen( $this->content[$name] )
                 )
             );
+
+            $propertyStorage->attach(
+                new ezcWebdavResourceTypeProperty(
+                    ( $isCollection === true ? 
ezcWebdavResourceTypeProperty::TYPE_COLLECTION : 
ezcWebdavResourceTypeProperty::TYPE_RESSOURCE )
+                )
+            );
         }
         else
         {

Modified: trunk/Webdav/src/properties/getcontentlength.php
==============================================================================
--- trunk/Webdav/src/properties/getcontentlength.php [iso-8859-1] (original)
+++ trunk/Webdav/src/properties/getcontentlength.php [iso-8859-1] Tue Sep 25 
15:46:43 2007
@@ -23,7 +23,7 @@
      * property set. It does not define what should be returned for
      * collections. We use the string in this constant for this.
      */
-    const COLLECTION = '-1';
+    const COLLECTION = '4096';
 
     /**
      * Creates a new ezcWebdavGetContentLengthProperty.

Modified: trunk/Webdav/src/properties/resourcetype.php
==============================================================================
--- trunk/Webdav/src/properties/resourcetype.php [iso-8859-1] (original)
+++ trunk/Webdav/src/properties/resourcetype.php [iso-8859-1] Tue Sep 25 
15:46:43 2007
@@ -18,16 +18,21 @@
  */
 class ezcWebdavResourceTypeProperty extends ezcWebdavLiveProperty
 {
+    const TYPE_RESSOURCE = 1;
+
+    const TYPE_COLLECTION = 2;
+    
     /**
      * Creates a new ezcWebdavResourceTypeProperty.
      * 
-     * @param string $type The resource type.
+     * @param int $type [EMAIL PROTECTED] self::TYPE_COLLECTION} or [EMAIL 
PROTECTED] self::TYPE_RESSOURCE}.
      * @return void
      */
     public function __construct( $type = null )
     {
         parent::__construct( 'resourcetype' );
 
+        $this->properties['type'] = null;
         $this->type = $type;
     }
 
@@ -51,9 +56,9 @@
         switch ( $propertyName )
         {
             case 'type':
-                if ( is_string( $propertyValue ) === false && $propertyValue 
!== null )
+                if ( $propertyValue !== self::TYPE_RESSOURCE && $propertyValue 
!== self::TYPE_COLLECTION && $propertyValue !== null )
                 {
-                    return $this->hasError( $propertyName, $propertyValue, 
'string' );
+                    return $this->hasError( $propertyName, $propertyValue, 
'ezcWebdavResourceTypeProperty::TYPE_RESSOURCE, 
ezcWebdavResourceTypeProperty::TYPE_COLLECTION or null' );
                 }
 
                 $this->properties[$propertyName] = $propertyValue;

Modified: trunk/Webdav/src/response/get_collection.php
==============================================================================
--- trunk/Webdav/src/response/get_collection.php [iso-8859-1] (original)
+++ trunk/Webdav/src/response/get_collection.php [iso-8859-1] Tue Sep 25 
15:46:43 2007
@@ -30,6 +30,7 @@
         parent::__construct( ezcWebdavResponse::STATUS_200 );
 
         $this->collection = $collection;
+        $this->setHeader( 'Content-Length', '4096' );
     }
 
     /**

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Tue Sep 25 15:46:43 2007
@@ -1485,7 +1485,7 @@
                 break;
             case 'ezcWebdavGetContentTypeProperty':
                 $elementName  = 'getcontenttype';
-                $elementValue = ( $property->mime !== null ? $property->mime . 
( $property->charset === null ? '' : '; charset=' . $property->charset ) : null 
);
+                $elementValue = ( $property->mime !== null ? $property->mime . 
( $property->charset === null ? '' : '; charset="' . $property->charset . '"' ) 
: null );
                 break;
             case 'ezcWebdavGetEtagProperty':
                 $elementName  = 'getetag';
@@ -1493,7 +1493,7 @@
                 break;
             case 'ezcWebdavGetLastModifiedProperty':
                 $elementName  = 'getlastmodified';
-                $elementValue = ( $property->date !== null ? 
$property->date->format( DATE_ISO8601 ) : null );
+                $elementValue = ( $property->date !== null ? 
$property->date->format( DATE_RFC1123 ) : null );
                 break;
             case 'ezcWebdavLockDiscoveryProperty':
                 $elementName  = 'lockdiscovery';
@@ -1501,7 +1501,7 @@
                 break;
             case 'ezcWebdavResourceTypeProperty':
                 $elementName  = 'resourcetype';
-                $elementValue = ( $property->type === 'collection' ? new 
DOMElement( 'D:collection', null, self::DEFAULT_NAMESPACE ) : null );
+                $elementValue = ( $property->type === 
ezcWebdavResourceTypeProperty::TYPE_COLLECTION ? $this->newDomElement( 
$parentElement->ownerDocument, 'collection' ) : null );
                 break;
             case 'ezcWebdavSourceProperty':
                 $elementName  = 'source';

Modified: trunk/Webdav/tests/backend_memory_test.php
==============================================================================
--- trunk/Webdav/tests/backend_memory_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/backend_memory_test.php [iso-8859-1] Tue Sep 25 15:46:43 
2007
@@ -157,6 +157,11 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty( '3' )
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE
+            )
+        );
 
         $props = $this->readAttribute( $backend, 'props' );
         $this->assertEquals(
@@ -267,6 +272,11 @@
             new ezcWebdavGetContentLengthProperty( '3' )
         );
         $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE
+            )
+        );
+        $propertyStorage->attach(
             new ezcWebdavDeadProperty( 'wcv:', 'ctime', '123456' )
         );
 
@@ -463,6 +473,11 @@
         );
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty( '3' )
+        );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE
+            )
         );
 
         $request = new ezcWebdavGetRequest( '/foo' );
@@ -1780,7 +1795,7 @@
         $prop1c->date = new DateTime( '@1124118780' );
         $prop200c->attach( $prop1c );
         $prop2c = clone $prop2;
-        $prop2c->length = '-1';
+        $prop2c->length = '4096';
         $prop200c->attach( $prop2c );
 
         $prop404c = new ezcWebdavPropertyStorage();
@@ -1876,6 +1891,9 @@
         $propertyStorage->attach(
             $test = new ezcWebdavGetContentLengthProperty()
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty()
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -1935,6 +1953,9 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty()
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty()
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -2008,6 +2029,9 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty()
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty()
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -2073,6 +2097,9 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty()
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty()
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -2154,6 +2181,9 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty()
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty()
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -2245,6 +2275,11 @@
         $propertyStorage->attach(
             new ezcWebdavGetContentLengthProperty( '3' )
         );
+        $propertyStorage->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE
+            )
+        );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(
             new ezcWebdavPropFindResponse(
@@ -2304,6 +2339,11 @@
         $propertyStorageC->attach(
             new ezcWebdavGetContentLengthProperty( 
ezcWebdavGetContentLengthProperty::COLLECTION )
         );
+        $propertyStorageC->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_COLLECTION
+            )
+        );
 
         $propertyStorageR = new ezcWebdavPropertyStorage();
         $propertyStorageR->attach(
@@ -2326,6 +2366,11 @@
         );
         $propertyStorageR->attach(
             new ezcWebdavGetContentLengthProperty( '19' )
+        );
+        $propertyStorageR->attach(
+            new ezcWebdavResourceTypeProperty(
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE
+            )
         );
 
         $expectedResponse = new ezcWebdavMultistatusResponse(

Modified: trunk/Webdav/tests/client_test_rfc_backend.php
==============================================================================
--- trunk/Webdav/tests/client_test_rfc_backend.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/client_test_rfc_backend.php [iso-8859-1] Tue Sep 25 
15:46:43 2007
@@ -230,6 +230,9 @@
     protected static function getFooBarSetup3( ezcWebdavClientTest $test )
     {
         $test->backend = new ezcWebdavMemoryBackend();
+        $test->backend->options->failForRegexp     = '(bar.html)';
+        $test->backend->options->failingOperations = 
ezcWebdavMemoryBackendOptions::REQUEST_PROPPATCH;
+        
         $test->backend->addContents(
             array(
                 'bar.html' => ''

Modified: trunk/Webdav/tests/clients/rfc/get_collection/response/result.ser
==============================================================================
--- trunk/Webdav/tests/clients/rfc/get_collection/response/result.ser 
[iso-8859-1] (original)
+++ trunk/Webdav/tests/clients/rfc/get_collection/response/result.ser 
[iso-8859-1] Tue Sep 25 15:46:43 2007
@@ -1,1 +1,1 @@
-a:2:{s:7:"headers";a:1:{i:0;s:15:"HTTP/1.1 200 OK";}s:4:"body";s:0:"";}
+a:2:{s:7:"headers";a:2:{i:0;s:15:"HTTP/1.1 200 
OK";s:14:"Content-Length";s:4:"4096";}s:4:"body";s:0:"";}

Modified: trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser
==============================================================================
--- trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser [iso-8859-1] 
(original)
+++ trunk/Webdav/tests/clients/rfc/proppatch/response/result.ser [iso-8859-1] 
Tue Sep 25 15:46:43 2007
@@ -1,1 +1,1 @@
-a:2:{s:7:"headers";a:1:{i:0;s:15:"HTTP/1.1 200 OK";}s:4:"body";s:0:"";}
+a:2:{s:7:"headers";a:1:{i:0;s:25:"HTTP/1.1 207 
Multi-Status";}s:4:"body";s:0:"";}

Modified: trunk/Webdav/tests/property_resourcetype_test.php
==============================================================================
--- trunk/Webdav/tests/property_resourcetype_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/property_resourcetype_test.php [iso-8859-1] Tue Sep 25 
15:46:43 2007
@@ -19,14 +19,16 @@
         $this->workingValues = array(
             'type' => array(
                 null,
-                '',
-                'Foo Bar Baz',
+                ezcWebdavResourceTypeProperty::TYPE_COLLECTION,
+                ezcWebdavResourceTypeProperty::TYPE_RESSOURCE,
             ),
         );
         $this->failingValues = array(
             'type' => array(
                 23,
                 23.34,
+                '',
+                'foo',
                 true,
                 false,
                 array( 23, 42 ),


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

Reply via email to