Author: ts
Date: Thu Sep 20 12:53:27 2007
New Revision: 6216
Log:
- Refactored ezcWebdavPathfactory.
- Added standard path factory as ezcWebdavAutomaticPathFactory.
- Moved ezcWebdavServerOptions to become ezcWebdavTransportOptions.
Added:
trunk/Webdav/src/path_factory/
trunk/Webdav/src/path_factory/automatic.php (with props)
Modified:
trunk/Webdav/design/class_diagram.png
trunk/Webdav/src/options/server.php
trunk/Webdav/src/path_factory.php
trunk/Webdav/src/response/propfind.php
trunk/Webdav/src/server.php
trunk/Webdav/src/transport.php
trunk/Webdav/src/webdav_autoload.php
trunk/Webdav/tests/client_test.php
trunk/Webdav/tests/client_test_rfc_backend.php
trunk/Webdav/tests/path_factory_test.php
trunk/Webdav/tests/server_options_test.php
trunk/Webdav/tests/suite.php
Modified: trunk/Webdav/design/class_diagram.png
==============================================================================
Binary files - no diff available.
Modified: trunk/Webdav/src/options/server.php
==============================================================================
--- trunk/Webdav/src/options/server.php [iso-8859-1] (original)
+++ trunk/Webdav/src/options/server.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -1,6 +1,6 @@
<?php
/**
- * File containing the ezcWebdavServerOptions class
+ * File containing the ezcWebdavTransportOptions class
*
* @package Webdav
* @version //autogen//
@@ -11,15 +11,13 @@
/**
* Class containing the options for basic webdav server.
*
- * @property string $pathFactory
+ * @property ezcWebdavPathFactory $pathFactory
* Class used to transform real paths into request paths.
- * @property bool $modSendfile
- * Server module mod_sendfile may be used for file sendouts.
*
* @package Webdav
* @version //autogen//
*/
-class ezcWebdavServerOptions extends ezcBaseOptions
+class ezcWebdavTransportOptions extends ezcBaseOptions
{
/**
* Constructs an object with the specified values.
@@ -32,8 +30,7 @@
*/
public function __construct( array $options = array() )
{
- $this->properties['pathFactory'] = 'ezcWebdavPathFactory';
- $this->properties['modSendfile'] = false;
+ $this->properties['pathFactory'] = new ezcWebdavPathFactory();
parent::__construct( $options );
}
@@ -49,32 +46,20 @@
* @param mixed $value
* @ignore
*/
- public function __set( $name, $value )
+ public function __set( $propertyName, $propertyValue )
{
- switch ( $name )
+ switch ( $propertyName )
{
case 'pathFactory':
- if ( !is_string( $value ) ||
- !is_subclass_of( $value, 'ezcWebdavPathFactory' ) )
+ if ( is_object( $propertyValue ) === false || ( $propertyValue
instanceof ezcWebdavPathFactory ) === false )
{
- throw new ezcBaseValueException( $name, $value,
'ezcWebdavPathFactory' );
+ throw new ezcBaseValueException( $propertyName,
$propertyValue, 'ezcWebdavPathFactory' );
}
-
- $this->properties[$name] = $value;
break;
-
- case 'modSendfile':
- if ( !is_bool( $value ) )
- {
- throw new ezcBaseValueException( $name, $value, 'bool' );
- }
-
- $this->properties[$name] = $value;
- break;
-
default:
- throw new ezcBasePropertyNotFoundException( $name );
+ throw new ezcBasePropertyNotFoundException( $propertyName );
}
+ $this->properties[$propertyName] = $propertyValue;
}
}
?>
Modified: trunk/Webdav/src/path_factory.php
==============================================================================
--- trunk/Webdav/src/path_factory.php [iso-8859-1] (original)
+++ trunk/Webdav/src/path_factory.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -8,21 +8,18 @@
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
- * This class is meant to calculate the path of the requested item from the
- * backend based on the given path by the webdav client. The resulting path
- * string is absolute to the root of the backend repository.
+ * Basic path factory.
*
- * This class is necessary to calculate the correct path when a server uses
- * rewrite rules for mapping directories to one or more webdav implementations.
- * The basic class uses pathinfo to parse the requested file / collection.
+ * An object of this class is meant to be used in [EMAIL PROTECTED]
+ * ezcWebdavTransportOptions} as the $pathFactory property. The instance of
+ * [EMAIL PROTECTED] ezcWebdavTransport} utilizes the path factory to
translate between
+ * external pathes/URIs and internal path representations.
*
- * Request: /path/to/webdav.php/path/to/file
- * Result: /path/to/file
+ * This simple implementation of a path factory expects the base URI it should
+ * be working on as the ctor parameter. It will translate all incoming URIs to
+ * internal pathes and the other way round based on this basis URI.
*
* You may want to provide custome implementations for different mappings.
- *
- * @properties ezcWebdavBackend $backend
- * Data backend used to serve the request.
*
* @version //autogentag//
* @package Webdav
@@ -30,86 +27,56 @@
class ezcWebdavPathFactory
{
/**
- * Parses a given path into a path object representing a file or collection
- * in the backend.
- *
- * This method is not only called for the initial requested path, but also
- * for every ressource in the request body.
- *
- * The optional parameter base is required to calculate a proper absolute
- * path when a relative path was given. The base path should always already
- * be a valid absolute repository path.
- *
- * @param string $requestPath
- * @return string
+ * Result of parse_url() for the [EMAIL PROTECTED] $baseUri} submitted to
the ctor.
+ *
+ * @var array(string=>string)
*/
- public static function parsePath( $requestPath, $base = null )
+ protected $baseUriParts;
+
+ public function __construct( $baseUri = '' )
{
- if ( $base !== null )
- {
- return self::handleRelativePath( $requestPath, $base );
- }
- else
- {
- return self::handleRequestUri( $requestPath );
- }
+ $this->baseUriParts = parse_url( $baseUri );
}
/**
- * Handle request URI and determine requested Webdav path using the server
- * variables containing the script file name and the document root.
- *
- * @param string $requestPath
+ * Parses the given URI to a locally understandable path.
+ *
+ * This method retrieves a URI (either full qualified or relative) and
+ * translates it into a local path, which can be understood by the WebDAV
+ * elements.
+ *
+ * @param string $uri
* @return string
*/
- protected static function handleRequestUri( $requestPath )
+ public function parseUriToPath( $uri )
{
- // Get Docroot and ensure proper definition
- if ( !isset( $_SERVER['DOCUMENT_ROOT'] ) )
- {
- throw new ezcWebdavMissingServerVariableException( 'DOCUMENT_ROOT'
);
- }
+ $requestPath = parse_url( $uri, PHP_URL_PATH );
- // Ensure trailing slash in doc root.
- $docRoot = $_SERVER['DOCUMENT_ROOT'];
- if ( $docRoot[strlen( $docRoot ) - 1] !== '/' )
- {
- $docRoot .= '/';
- }
+ return substr( $requestPath, strlen( $this->baseUriParts['path'] ) );
+ }
- // Get script filename
- if ( !isset( $_SERVER['SCRIPT_FILENAME'] ) )
- {
- throw new ezcWebdavMissingServerVariableException(
'SCRIPT_FILENAME' );
- }
-
- $scriptFileName = $_SERVER['SCRIPT_FILENAME'];
-
- // Get script path absolute to doc root
- $serverFile = '/' . str_replace(
- $docRoot, '', $scriptFileName
- );
-
- // Check for proper request path
- if ( strpos( $requestPath, $serverFile ) !== 0 )
- {
- // Request URI should always start with server file, othwise there
- // is some rewriting in place, which cannot be handled using this
- // path factory
- throw new ezcWebdavBrokenRequestUriException( $requestPath );
-
- }
-
- // Get ressource.
- $ressource = substr( $requestPath, strlen( $serverFile ) );
-
- // Ressource may be empty for requests on webdav root
- if ( empty( $ressource ) )
- {
- $ressource = '/';
- }
-
- return $ressource;
+ /**
+ * Generates a URI from a local path.
+ *
+ * This method receives a local $path string, representing a node in the
+ * local WebDAV store and translates it into a full qualified URI to be
+ * used as external reference.
+ *
+ * @param string $path
+ * @return string
+ */
+ public function generateUriFromPath( $path )
+ {
+ return $this->baseUriParts['scheme']
+ . '://' . $this->baseUriParts['host']
+ . ( isset( $this->baseUriParts['user'] ) ?
$this->baseUriParts['user'] : '' )
+ . ( isset( $this->baseUriParts['pass'] ) ? ':' .
$this->baseUriParts['pass'] : '' )
+ . ( isset( $this->baseUriParts['user'] ) || isset(
$this->baseUriParts['pass'] ) ? '@' : '' )
+ . $this->baseUriParts['host']
+ . $this->baseUriParts['path']
+ . $path
+ . ( isset( $this->baseUriParts['query'] ) ? '?' .
$this->baseUriParts['query'] : '' )
+ . ( isset( $this->baseUriParts['fragment'] ) ? '#' .
$this->baseUriParts['fragment'] : '' );
}
}
Added: trunk/Webdav/src/path_factory/automatic.php
==============================================================================
--- trunk/Webdav/src/path_factory/automatic.php (added)
+++ trunk/Webdav/src/path_factory/automatic.php [iso-8859-1] Thu Sep 20
12:53:27 2007
@@ -1,0 +1,121 @@
+<?php
+/**
+ * File containing the ezcWebdavAutomaticPathFactory class.
+ *
+ * @package Webdav
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Path factory that automatically detects local settings.
+ *
+ * This class is necessary to calculate the correct path when a server uses
+ * rewrite rules for mapping directories to one or more webdav implementations.
+ * The basic class uses pathinfo to parse the requested file / collection.
+ *
+ * Request: /path/to/webdav.php/path/to/file
+ * Result: /path/to/file
+ *
+ * You may want to provide custome implementations for different mappings.
+ *
+ * @version //autogentag//
+ * @package Webdav
+ */
+class ezcWebdavAutomaticPathFactory extends ezcWebdavPathFactory
+{
+ /**
+ * Base path on the server.
+ *
+ * Auto-detected during __construct().
+ *
+ * @var string
+ */
+ protected $serverFile;
+
+ /**
+ * Creates a new path factory.
+ *
+ * Creates a new path factory to be used in ezcWebdavTransportOptions. This
+ * path factory automatically detects information from the running
+ * webserver and tries to automatically determine the suitable values.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ // Get Docroot and ensure proper definition
+ if ( !isset( $_SERVER['DOCUMENT_ROOT'] ) )
+ {
+ throw new ezcWebdavMissingServerVariableException( 'DOCUMENT_ROOT'
);
+ }
+
+ // Ensure trailing slash in doc root.
+ $docRoot = $_SERVER['DOCUMENT_ROOT'];
+ if ( substr( $docRoot, -1, 1 ) !== '/' )
+ {
+ $docRoot .= '/';
+ }
+
+ // Get script filename
+ if ( !isset( $_SERVER['SCRIPT_FILENAME'] ) )
+ {
+ throw new ezcWebdavMissingServerVariableException(
'SCRIPT_FILENAME' );
+ }
+
+ $scriptFileName = $_SERVER['SCRIPT_FILENAME'];
+
+ // Get script path absolute to doc root
+ $this->serverFile = '/' . str_replace(
+ $docRoot, '', $scriptFileName
+ );
+ }
+
+ /**
+ * Parses the given URI to a locally understandable path.
+ *
+ * This method retrieves a URI (either full qualified or relative) and
+ * translates it into a local path, which can be understood by the WebDAV
+ * elements.
+ *
+ * @param string $uri
+ * @return string
+ */
+ public function parseUriToPath( $uri )
+ {
+ $requestPath = parse_url( $uri, PHP_URL_PATH );
+
+ // Check for proper request path
+ if ( strpos( $requestPath, $this->serverFile ) !== 0 )
+ {
+ // Request URI should always start with server file, othwise there
+ // is some rewriting in place, which cannot be handled using this
+ // path factory
+ throw new ezcWebdavBrokenRequestUriException( $requestPath );
+ }
+
+ // Get ressource.
+ $path = substr( $requestPath, strlen( $this->serverFile ) );
+ return ( is_string( $path ) ? $path : '' );
+ }
+
+ /**
+ * Generates a URI from a local path.
+ *
+ * This method receives a local $path string, representing a node in the
+ * local WebDAV store and translates it into a full qualified URI to be
+ * used as external reference.
+ *
+ * @param string $path
+ * @return string
+ */
+ public function generateUriFromPath( $path )
+ {
+ return 'http://' . $_SERVER['SERVER_NAME']
+ . ( $_SERVER['SERVER_PORT'] == 80 ? '' : ':' .
$_SERVER['SERVER_PORT'] )
+ . $this->serverFile
+ . $path;
+ }
+}
+
+?>
Propchange: trunk/Webdav/src/path_factory/automatic.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/Webdav/src/response/propfind.php
==============================================================================
--- trunk/Webdav/src/response/propfind.php [iso-8859-1] (original)
+++ trunk/Webdav/src/response/propfind.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -68,7 +68,7 @@
}
// If it actually consists of multiple sub responses be of type 207.
- if ( count( $responses ) )
+ if ( count( $responses ) > 0 )
{
$this->status = ezcWebdavResponse::STATUS_207;
}
Modified: trunk/Webdav/src/server.php
==============================================================================
--- trunk/Webdav/src/server.php [iso-8859-1] (original)
+++ trunk/Webdav/src/server.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -15,9 +15,6 @@
*
* // Server data using file backend with data in "path/"
* $server->backend = new ezcWebdavBackendFile( '/path' );
- *
- * // Optionally set some server options
- * $server->options->modSendfile = true;
*
* // Optionally register aditional transport handlers
* //
@@ -48,12 +45,6 @@
*/
class ezcWebdavServer
{
- /**
- * Server option class
- *
- * @var ezcWebdavServerOptions
- */
- protected $options;
/**
* Array with available transport handlers. The key of this array is a
@@ -101,59 +92,7 @@
*/
public function __construct( ezcWebdavBackend $backend = null )
{
- $this->options = new ezcWebdavServerOptions();
-
// @TODO: Implement
- }
-
- /**
- * Offer access to some of the server properties.
- *
- * @throws ezcBasePropertyNotFoundException
- * If the property $name is not defined
- * @param string $name
- * @return mixed
- * @ignore
- */
- public function __get( $name )
- {
- switch ( $name )
- {
- case 'options':
- return $this->$name;
-
- default:
- throw new ezcBasePropertyNotFoundException( $name );
- }
- }
-
- /**
- * Sets the option $name to $value.
- *
- * @throws ezcBasePropertyNotFoundException
- * if the property $name is not defined
- * @throws ezcBaseValueException
- * if $value is not correct for the property $name
- * @param string $name
- * @param mixed $value
- * @ignore
- */
- public function __set( $name, $value )
- {
- switch ( $name )
- {
- case 'options':
- if ( ! $value instanceof ezcWebdavServerOptions )
- {
- throw new ezcBaseValueException( $name, $value,
'ezcWebdavServerOptions' );
- }
-
- $this->$name = $value;
- break;
-
- default:
- throw new ezcBasePropertyNotFoundException( $name );
- }
}
/**
@@ -266,31 +205,6 @@
return false;
}
}
-
- /**
- * Get parsed path using the configured path factory class defined in the
- * server option parseFactory. You may change the used class by setting
- * another class for this, which inherits from [EMAIL PROTECTED]
- * ezcWebdavPathFactory}.
- *
- * <code>
- * $server->options->pathFactory = 'myPathFactory';
- * </code>
- *
- * @param mixed $path
- * @param mixed $base
- * @access public
- * @return void
- */
- public function getParsedPath( $path, $base = null )
- {
- // Just dispatch call to configured pathFactory class.
- return call_user_func(
- array( $this->options->pathFactory, 'parsePath' ),
- $path,
- $base
- );
- }
}
?>
Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -19,6 +19,21 @@
*/
class ezcWebdavTransport
{
+ /**
+ * Properties.
+ *
+ * @var array()
+ */
+ protected $properties = array();
+
+ public function __construct( ezcWebdavTransportOptions $options = null )
+ {
+ if ( $options === null )
+ {
+ $options = new ezcWebdavTransportOptions();
+ }
+ $this->properties['options'] = $options;
+ }
/**
* Map of regular header names to $_SERVER keys.
@@ -799,7 +814,84 @@
*/
public function handleResponse( ezcWebdavResponse $response )
{
- // @TODO: Implement
+ switch ( get_class( $response ) )
+ {
+ case 'ezcWebdavCopyResponse':
+ case 'ezcWebdavDeleteResponse':
+ case 'ezcWebdavErrorResponse':
+ case 'ezcWebdavGetCollectionResponse':
+ case 'ezcWebdavGetResourceResponse':
+ case 'ezcWebdavHeadResponse':
+ case 'ezcWebdavMakeCollectionResponse':
+ case 'ezcWebdavMoveResponse':
+ case 'ezcWebdavMultiStatusResponse':
+ case 'ezcWebdavOptionsResponse':
+ case 'ezcWebdavPropPatchResponse':
+ case 'ezcWebdavPutResponse':
+ // @TODO: Implement!
+ throw new RuntimeException( 'Not implemented, yet.' );
+
+ case 'ezcWebdavPropFindResponse':
+ $this->handlePropFindResponse( $response );
+ break;
+ }
+ }
+
+ protected function handlePropFindResponse( ezcWebdavPropFindResponse
$response )
+ {
+ $dom = new DOMDocument();
+ }
+
+ /**
+ * Offer access to some of the server properties.
+ *
+ * @throws ezcBasePropertyNotFoundException
+ * If the property $propertyName is not defined
+ * @param string $propertyName
+ * @return mixed
+ * @ignore
+ */
+ public function __get( $propertyName )
+ {
+ if ( $this->__isset( $propertyName ) === false )
+ {
+ throw new ezcBasePropertyNotFoundException( $propertyName );
+ }
+
+ return $this->properties[$propertyName];
+ }
+
+ /**
+ * Sets the option $propertyName to $propertyValue.
+ *
+ * @throws ezcBasePropertyNotFoundException
+ * if the property $propertyName is not defined
+ * @throws ezcBaseValueException
+ * if $propertyValue is not correct for the property $propertyName
+ * @param string $propertyName
+ * @param mixed $propertyValue
+ * @ignore
+ */
+ public function __set( $propertyName, $propertyValue )
+ {
+ switch ( $propertyName )
+ {
+ case 'options':
+ if ( ( $propertyValue instanceof ezcWebdavTransportOptions )
=== false )
+ {
+ throw new ezcBaseValueException( $propertyName,
$propertyValue, 'ezcWebdavTransportOptions' );
+ }
+ break;
+
+ default:
+ throw new ezcBasePropertyNotFoundException( $propertyName );
+ }
+ $this->properties[$propertyName] = $propertyValue;
+ }
+
+ public function __isset( $propertyName )
+ {
+ return array_key_exists( $propertyName, $this->properties );
}
}
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] Thu Sep 20 12:53:27 2007
@@ -29,11 +29,13 @@
'ezcWebdavLiveProperty' =>
'Webdav/interfaces/property_live.php',
'ezcWebdavResponse' =>
'Webdav/interfaces/response.php',
'ezcWebdavCopyResponse' => 'Webdav/response/copy.php',
+ 'ezcWebdavPathFactory' => 'Webdav/path_factory.php',
'ezcWebdavPropFindResponse' =>
'Webdav/response/propfind.php',
'ezcWebdavPropertyStorage' =>
'Webdav/property_storage.php',
'ezcWebdavRequest' =>
'Webdav/interfaces/request.php',
'ezcWebdavSimpleBackend' => 'Webdav/backend/simple.php',
'ezcWebdavSupportedLockPropertyLockentry' =>
'Webdav/properties/supportedlock_lockentry.php',
+ 'ezcWebdavAutomaticPathFactory' =>
'Webdav/path_factory/automatic.php',
'ezcWebdavCollection' =>
'Webdav/structs/collection.php',
'ezcWebdavCopyRequest' => 'Webdav/request/copy.php',
'ezcWebdavCreationDateProperty' =>
'Webdav/properties/creationdate.php',
@@ -65,7 +67,6 @@
'ezcWebdavMultistatusResponse' =>
'Webdav/response/multistatus.php',
'ezcWebdavOptionsRequest' => 'Webdav/request/options.php',
'ezcWebdavOptionsResponse' =>
'Webdav/response/options.php',
- 'ezcWebdavPathFactory' => 'Webdav/path_factory.php',
'ezcWebdavPropFindRequest' =>
'Webdav/request/propfind.php',
'ezcWebdavPropPatchRequest' =>
'Webdav/request/proppatch.php',
'ezcWebdavPropPatchResponse' =>
'Webdav/response/proppatch.php',
@@ -77,11 +78,11 @@
'ezcWebdavResource' =>
'Webdav/structs/resource.php',
'ezcWebdavResourceTypeProperty' =>
'Webdav/properties/resourcetype.php',
'ezcWebdavServer' => 'Webdav/server.php',
- 'ezcWebdavServerOptions' => 'Webdav/options/server.php',
'ezcWebdavSourceProperty' =>
'Webdav/properties/source.php',
'ezcWebdavSourcePropertyLink' =>
'Webdav/properties/source_link.php',
'ezcWebdavSupportedLockProperty' =>
'Webdav/properties/supportedlock.php',
'ezcWebdavTransport' => 'Webdav/transport.php',
+ 'ezcWebdavTransportOptions' => 'Webdav/options/server.php',
'ezcWebdavUnlockRequest' => 'Webdav/request/unlock.php',
);
?>
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] Thu Sep 20 12:53:27 2007
@@ -222,7 +222,7 @@
}
break;
case 'ezcWebdavPutRequest':
- if ( $requestObject instanceof ezcWebdavBackendPut )
+ if ( ( $requestObject instanceof ezcWebdavBackendPut ) ===
false )
{
$responseObject = $response['backend']->put(
$requestObject );
}
@@ -243,6 +243,7 @@
foreach ( $response['headers'] as $headerName => $headerValue )
{
+ // Headers can only be set after XML generation
if ( $headerName !== 'Content-Type' && $headerName !==
'Content-Length' )
{
$this->assertEquals(
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] Thu Sep 20
12:53:27 2007
@@ -12,7 +12,10 @@
case 'propfind_allprop':
case 'move_collection':
case 'copy_collection':
+ case 'delete':
return self::getFooBarSetup();
+ case 'propfind_prop':
+ return self::getFooBar2Setup();
default:
throw new RuntimeException( "Could not find setup for test set
'$testSetName'." );
}
@@ -160,6 +163,45 @@
return $backend;
}
+
+ protected static function getFooBar2Setup()
+ {
+ $backend = new ezcWebdavMemoryBackend();
+ $backend->addContents(
+ array(
+ 'file' => ''
+ )
+ );
+
+ $backend->setProperty(
+ '/file',
+ new ezcWebdavDeadProperty(
+ 'http://www.foo.bar/boxschema/',
+ 'bigbox',
+ <<<EOT
+<?xml version="1.0" encoding="utf-8" ?>
+<R:bigbox xmlns:R="http://www.foo.bar/boxschema/">
+<R:BoxType>Box type A</R:BoxType>
+</R:bigbox>
+EOT
+ )
+ );
+ $backend->setProperty(
+ '/file',
+ new ezcWebdavDeadProperty(
+ 'http://www.foo.bar/boxschema/',
+ 'author',
+ <<<EOT
+<?xml version="1.0" encoding="utf-8" ?>
+<R:author xmlns:R="http://www.foo.bar/boxschema/">
+<R:Name>J.J. Johnson</R:Name>
+</R:author>
+EOT
+ )
+ );
+
+ return $backend;
+ }
}
?>
Modified: trunk/Webdav/tests/path_factory_test.php
==============================================================================
--- trunk/Webdav/tests/path_factory_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/path_factory_test.php [iso-8859-1] Thu Sep 20 12:53:27
2007
@@ -20,16 +20,16 @@
require_once 'classes/custom_path_factory.php';
/**
- * Tests for ezcWebdavPathFactory class.
+ * Tests for ezcWebdavAutomaticPathFactory class.
*
* @package Webdav
* @subpackage Tests
*/
-class ezcWebdavPathFactoryTest extends ezcWebdavTestCase
+class ezcWebdavAutomaticPathFactoryTest extends ezcWebdavTestCase
{
public static function suite()
{
- return new PHPUnit_Framework_TestSuite(
'ezcWebdavPathFactoryTest' );
+ return new PHPUnit_Framework_TestSuite(
'ezcWebdavAutomaticPathFactoryTest' );
}
public function testPathDispatchingWithoutScriptFileName()
@@ -40,14 +40,12 @@
try
{
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] );
+ $factory = new ezcWebdavAutomaticPathFactory();
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] );
+
+ $this->fail( 'ezcWebdavMissingServerVariableException expected.' );
}
- catch ( ezcWebdavMissingServerVariableException $e )
- {
- return true;
- }
-
- $this->fail( 'ezcWebdavMissingServerVariableException expected.' );
+ catch ( ezcWebdavMissingServerVariableException $e ) {}
}
public function testPathDispatchingWithoutDocumentRoot()
@@ -58,14 +56,12 @@
try
{
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] );
+ $factory = new ezcWebdavAutomaticPathFactory();
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] );
+
+ $this->fail( 'ezcWebdavMissingServerVariableException expected.' );
}
- catch ( ezcWebdavMissingServerVariableException $e )
- {
- return true;
- }
-
- $this->fail( 'ezcWebdavMissingServerVariableException expected.' );
+ catch ( ezcWebdavMissingServerVariableException $e ) {}
}
public function testRootPathWithoutRewrite()
@@ -74,9 +70,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] = '/webdav.php/collection/ressource';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/collection/ressource'
+ '/collection/ressource',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -86,9 +83,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs';
$_SERVER['REQUEST_URI'] = '/webdav.php/collection/ressource';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/collection/ressource'
+ '/collection/ressource',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -98,9 +96,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] = '/webdav.php';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/'
+ '',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -110,9 +109,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] = '/webdav.php/';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/'
+ '/',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -122,9 +122,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] =
'/path/to/webdav.php/collection/ressource';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/collection/ressource'
+ '/collection/ressource',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -134,9 +135,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs';
$_SERVER['REQUEST_URI'] =
'/path/to/webdav.php/collection/ressource';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/collection/ressource'
+ '/collection/ressource',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -146,9 +148,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] = '/path/to/webdav.php';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/'
+ '',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -158,9 +161,10 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] = '/path/to/webdav.php/';
+ $factory = new ezcWebdavAutomaticPathFactory();
$this->assertSame(
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] ),
- '/'
+ '/',
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] )
);
}
@@ -170,46 +174,13 @@
$_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
$_SERVER['REQUEST_URI'] =
'/path/to/webdav/collection/ressource';
+ $factory = new ezcWebdavAutomaticPathFactory();
try
{
- ezcWebdavPathFactory::parsePath( $_SERVER['REQUEST_URI'] );
+ $factory->parseUriToPath( $_SERVER['REQUEST_URI'] );
+ $this->fail( 'ezcWebdavBrokenRequestUriException expected.' );
}
- catch ( ezcWebdavBrokenRequestUriException $e )
- {
- return true;
- }
-
- $this->fail( 'ezcWebdavBrokenRequestUriException expected.' );
- }
-
- public function testPathFactoryInServer()
- {
- $_SERVER['SCRIPT_FILENAME'] =
'/var/www/webdav/htdocs/path/to/webdav.php';
- $_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
- $_SERVER['REQUEST_URI'] = '/path/to/webdav.php/';
-
- $server = new ezcWebdavServer();
-
- $this->assertSame(
- $server->getParsedPath( $_SERVER['REQUEST_URI'] ),
- '/'
- );
- }
-
- public function testModifiedPathFactoryInServer()
- {
- $_SERVER['SCRIPT_FILENAME'] =
'/var/www/webdav/htdocs/path/to/webdav.php';
- $_SERVER['DOCUMENT_ROOT'] = '/var/www/webdav/htdocs/';
- $_SERVER['REQUEST_URI'] = '/path/to/webdav.php/';
-
- $server = new ezcWebdavServer();
-
- $server->options->pathFactory = 'myTestPathFactory';
-
- $this->assertSame(
- $server->getParsedPath( $_SERVER['REQUEST_URI'] ),
- 'This is only a test.'
- );
+ catch ( ezcWebdavBrokenRequestUriException $e ) {}
}
}
?>
Modified: trunk/Webdav/tests/server_options_test.php
==============================================================================
--- trunk/Webdav/tests/server_options_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/server_options_test.php [iso-8859-1] Thu Sep 20 12:53:27
2007
@@ -20,33 +20,53 @@
* @package Webdav
* @subpackage Tests
*/
-class ezcWebdavServerOptionsTest extends ezcWebdavTestCase
+class ezcWebdavTransportOptionsTest extends ezcWebdavTestCase
{
public static function suite()
{
- return new PHPUnit_Framework_TestSuite(
'ezcWebdavServerOptionsTest' );
+ return new PHPUnit_Framework_TestSuite(
'ezcWebdavTransportOptionsTest' );
}
- public function testServerOptionsInServer()
+ public function testTransportOptionsInServer()
{
- $server = new ezcWebdavServer();
+ $transport = new ezcWebdavTransport();
$this->assertEquals(
- $server->options,
- new ezcWebdavServerOptions(),
+ $transport->options,
+ new ezcWebdavTransportOptions(),
'Expected initially unmodified server options class.'
- );
-
- $this->assertSame(
- $server->options->modSendfile,
- false,
- 'Expected successfull access on option.'
);
try
{
- // Read access
- $server->unknownProperty;
+ $transport->options->unknownProperty;
+ $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
+ }
+ catch ( ezcBasePropertyNotFoundException $e ) {}
+ }
+
+ public function testTransportOptionsSetInServer()
+ {
+ $transport = new ezcWebdavTransport();
+
+ $options = new ezcWebdavTransportOptions();
+ $transport->options = $options;
+
+ $this->assertEquals(
+ $transport->options->pathFactory,
+ new ezcWebdavPathFactory()
+ );
+
+ $transport->options->pathFactory = new ezcWebdavAutomaticPathFactory();
+
+ $this->assertEquals(
+ $transport->options->pathFactory,
+ new ezcWebdavAutomaticPathFactory()
+ );
+
+ try
+ {
+ $transport->unknownProperty = $options;
}
catch ( ezcBasePropertyNotFoundException $e )
{
@@ -56,130 +76,54 @@
$this->fail( 'Expected ezcBasePropertyNotFoundException.' );
}
- public function testServerOptionsSetInServer()
+ public function testTransportOptionsUnknownRead()
{
- $server = new ezcWebdavServer();
+ $options = new ezcWebdavTransportOptions();
- $options = new ezcWebdavServerOptions();
- $options->modSendfile = true;
+ try
+ {
+ $options->unknownProperty;
+ $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
+ }
+ catch ( ezcBasePropertyNotFoundException $e ) {}
+ }
- $this->assertSame(
- $server->options->modSendfile,
- false,
- 'Wrong initial value before changed option class.'
+ public function testTransportOptionsUnknownWrite()
+ {
+ $options = new ezcWebdavTransportOptions();
+
+ try
+ {
+ $options->unknownProperty = 42;
+ $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
+ }
+ catch ( ezcBasePropertyNotFoundException $e ) {}
+ }
+
+ public function testTransportOptionsPathFactory()
+ {
+ $options = new ezcWebdavTransportOptions();
+
+ $this->assertEquals(
+ new ezcWebdavPathFactory(),
+ $options->pathFactory
);
- $server->options = $options;
+ $mockedPathFactory = $this->getMock( 'ezcWebdavPathFactory' );
+ $options->pathFactory = $mockedPathFactory;
$this->assertSame(
- $server->options->modSendfile,
- true,
- 'Expected modified value, because of changed option class.'
+ $mockedPathFactory,
+ $options->pathFactory
);
try
{
- $server->unknownProperty = $options;
+ $options->pathFactory = 'ezcWebdavTransportOptions';
+ $this->fail( 'Expected ezcBaseValueException.' );
}
- catch ( ezcBasePropertyNotFoundException $e )
- {
- return true;
- }
+ catch ( ezcBaseValueException $e ) {}
- $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
- }
-
- public function testServerOptionsModSendfile()
- {
- $options = new ezcWebdavServerOptions();
-
- $this->assertSame(
- false,
- $options->modSendfile,
- 'Wrong default value for property modSendfile in class
ezcWebdavServerOptions.'
- );
-
- $options->modSendfile = true;
- $this->assertSame(
- true,
- $options->modSendfile,
- 'Setting property value did not work for property modSendfile in
class ezcWebdavServerOptions.'
- );
-
- try
- {
- $options->modSendfile = 42;
- }
- catch ( ezcBaseValueException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcBaseValueException.' );
- }
-
- public function testServerOptionsUnknownRead()
- {
- $options = new ezcWebdavServerOptions();
-
- try
- {
- // Read access
- $options->unknownProperty;
- }
- catch ( ezcBasePropertyNotFoundException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
- }
-
- public function testServerOptionsUnknownWrite()
- {
- $options = new ezcWebdavServerOptions();
-
- try
- {
- $options->unknownProperty = 42;
- }
- catch ( ezcBasePropertyNotFoundException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcBasePropertyNotFoundException.' );
- }
-
- public function testServerOptionsPathFactory()
- {
- $options = new ezcWebdavServerOptions();
-
- $this->assertSame(
- 'ezcWebdavPathFactory',
- $options->pathFactory,
- 'Wrong default value for property pathFactory in class
ezcWebdavServerOptions.'
- );
-
- $mockedPathFactory = $this->getMock( 'ezcWebdavPathFactory' );
-
- $options->pathFactory = get_class( $mockedPathFactory );
- $this->assertSame(
- get_class( $mockedPathFactory ),
- $options->pathFactory,
- 'Setting property value did not work for property pathFactory in
class ezcWebdavServerOptions.'
- );
-
- try
- {
- $options->pathFactory = 'ezcWebdavServerOptions';
- }
- catch ( ezcBaseValueException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcBaseValueException.' );
}
}
?>
Modified: trunk/Webdav/tests/suite.php
==============================================================================
--- trunk/Webdav/tests/suite.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/suite.php [iso-8859-1] Thu Sep 20 12:53:27 2007
@@ -79,7 +79,7 @@
$this->setName( 'Webdav' );
$this->addTest( ezcWebdavBasicServerTest::suite() );
- $this->addTest( ezcWebdavServerOptionsTest::suite() );
+ $this->addTest( ezcWebdavTransportOptionsTest::suite() );
$this->addTest( ezcWebdavFlaggedPropertyStorageTest::suite() );
$this->addTest( ezcWebdavPropertyStorageTest::suite() );
@@ -115,7 +115,7 @@
$this->addTest( ezcWebdavMemoryBackendTest::suite() );
- $this->addTest( ezcWebdavPathFactoryTest::suite() );
+ $this->addTest( ezcWebdavAutomaticPathFactoryTest::suite() );
$this->addTest( ezcWebdavClientRfcTest::suite() );
$this->addTest( ezcWebdavClientCadaverTest::suite() );
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components