Author: ts
Date: Tue Sep 25 06:24:29 2007
New Revision: 6255
Log:
- Refactored test infrastructure.
Added:
trunk/Webdav/tests/client_test_cadaver_backend.php (with props)
Modified:
trunk/Webdav/tests/client_test.php
trunk/Webdav/tests/client_test_cadaver.php
trunk/Webdav/tests/client_test_rfc.php
trunk/Webdav/tests/client_test_rfc_backend.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] Tue Sep 25 06:24:29 2007
@@ -1,15 +1,16 @@
<?php
+
+libxml_use_internal_errors( true );
abstract class ezcWebdavClientTest extends ezcTestCase
{
-
- protected $dataDir;
-
- protected $transport;
-
protected $setupClass;
- protected $pathFactory = 'ezcWebdavPathFactory';
+ public $dataDir;
+
+ public $transport;
+
+ public $backend;
private $testSets = array();
@@ -60,7 +61,8 @@
protected function runTestSet( $testSetName )
{
- libxml_use_internal_errors( true );
+ call_user_func( array( $this->setupClass, 'performSetup' ), $this,
basename( $testSetName ) );
+
$requestObject = null;
$serverBase = array(
@@ -93,7 +95,6 @@
$response['body'] = $this->getFileContent( $responseDir, 'body'
);
$response['code'] = $this->getFileContent( $responseDir, 'code'
);
$response['name'] = $this->getFileContent( $responseDir, 'name'
);
- $response['backend'] = call_user_func( array( $this->setupClass,
'getSetup' ), basename( $testSetName ) );
$responseObject = $this->runResponseTest( $response,
$requestObject );
}
@@ -120,7 +121,7 @@
break;
case 'txt':
default:
- $fileContent = file_get_contents( $filePath );
+ $fileContent = trim( file_get_contents( $filePath ) );
break;
}
return $fileContent;
@@ -160,7 +161,7 @@
protected function runResponseTest( array $response, ezcWebdavRequest
$requestObject )
{
- $responseObject = $response['backend']->performRequest( $requestObject
);
+ $responseObject = $this->backend->performRequest( $requestObject );
$this->transport->handleResponse( $responseObject );
$responseBody = $GLOBALS['EZC_WEBDAV_TRANSPORT_TEST_RESPONSE_BODY'];
@@ -174,7 +175,7 @@
"{$this->currentTestSet}/response/result.ser",
serialize( array( "headers" => $responseHeaders, "body" =>
$responseBody ) )
);
- if ( trim( $response['body'] ) === '' || $responseBody === null )
+ if ( isset( $response['body'] ) === false || trim(
$response['body'] ) === '' || $responseBody === '' )
{
$this->assertEquals(
$response['body'],
@@ -198,7 +199,7 @@
$responseHeaders,
'Generated headers missmatch.'
);
- if ( trim( $response['result']['body'] ) === '' || $responseBody
=== null )
+ if ( trim( $response['result']['body'] ) === '' || $responseBody
=== '' )
{
$this->assertEquals(
$response['result']['body'],
Modified: trunk/Webdav/tests/client_test_cadaver.php
==============================================================================
--- trunk/Webdav/tests/client_test_cadaver.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/client_test_cadaver.php [iso-8859-1] Tue Sep 25 06:24:29
2007
@@ -1,6 +1,7 @@
<?php
require_once 'classes/transport_test_mock.php';
+require_once 'client_test_cadaver_backend.php';
require_once 'client_test_suite.php';
require_once 'client_test.php';
@@ -9,11 +10,8 @@
{
protected function setupTestEnvironment()
{
- $this->transport = new ezcWebdavTransportTestMock();
- $this->transport->options->pathFactory = new ezcWebdavPathFactory(
- 'http://foo.bar'
- );
- $this->dataDir = dirname( __FILE__ ) . '/clients/cadaver';
+ $this->setupClass = 'ezcWebdavClientCadaverTestBackend';
+ $this->dataDir = dirname( __FILE__ ) . '/clients/cadaver';
}
public static function suite()
Added: trunk/Webdav/tests/client_test_cadaver_backend.php
==============================================================================
--- trunk/Webdav/tests/client_test_cadaver_backend.php (added)
+++ trunk/Webdav/tests/client_test_cadaver_backend.php [iso-8859-1] Tue Sep 25
06:24:29 2007
@@ -1,0 +1,164 @@
+<?php
+
+class ezcWebdavClientCadaverTestBackend
+{
+ public static function performSetup( ezcWebdavClientTest $test,
$testSetName )
+ {
+ $test->transport = new ezcWebdavTransportTestMock();
+ $test->transport->options->pathFactory = new ezcWebdavPathFactory(
+ 'http://foo.bar'
+ );
+
+ return self::getFooBarSetup1( $test );
+ }
+
+ protected static function getFooBarSetup1( ezcWebdavClientTest $test )
+ {
+ $test->backend = new
ezcWebdavMemoryBackend();
+ $test->backend->options->failForRegexp = '(container/resource3)';
+ $test->backend->options->failingOperations =
ezcWebdavMemoryBackendOptions::REQUEST_DELETE;
+
+ $test->backend->addContents(
+ array(
+ 'container' => array(
+ 'front.html' => '',
+ 'R2' => array(),
+ 'resource3' => '',
+ ),
+ )
+ );
+
+ $test->backend->setProperty(
+ '/container',
+ 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
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ 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>Hadrian</R:Name>
+</R:author>
+EOT
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavCreationDateProperty(
+ new DateTime( '1997-12-01T17:42:21-08:00' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavDisplayNameProperty(
+ 'Example collection'
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavResourceTypeProperty(
+ 'collection'
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavSupportedLockProperty(
+ array(
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_EXCLUSIVE
+ ),
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_SHARED
+ ),
+ )
+ )
+ );
+
+ $test->backend->setProperty(
+ '/container/front.html',
+ 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 B</R:BoxType>
+</R:bigbox>
+EOT
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavCreationDateProperty(
+ new DateTime( '1997-12-01T18:27:21-08:00' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavDisplayNameProperty(
+ 'Example HTML resource'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetContentLengthProperty(
+ '4525'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetContentTypeProperty(
+ 'text/html'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetEtagProperty(
+ 'zzyzx'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetLastModifiedProperty(
+ new DateTime( 'Monday, 12-Jan-98 09:25:56 GMT' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavResourceTypeProperty()
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavSupportedLockProperty(
+ array(
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_EXCLUSIVE
+ ),
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_SHARED
+ ),
+ )
+ )
+ );
+
+ return $test->backend;
+ }
+}
+
+?>
Propchange: trunk/Webdav/tests/client_test_cadaver_backend.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/Webdav/tests/client_test_rfc.php
==============================================================================
--- trunk/Webdav/tests/client_test_rfc.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/client_test_rfc.php [iso-8859-1] Tue Sep 25 06:24:29 2007
@@ -11,12 +11,8 @@
{
protected function setupTestEnvironment()
{
- $this->transport = new ezcWebdavTransportTestMock();
- $this->transport->options->pathFactory = new ezcWebdavPathFactory(
- 'http://foo.bar'
- );
+ $this->setupClass = 'ezcWebdavClientRfcTestBackend';
$this->dataDir = dirname( __FILE__ ) . '/clients/rfc';
- $this->setupClass = 'ezcWebdavClientRfcTestBackend';
}
public static function suite()
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
06:24:29 2007
@@ -2,8 +2,11 @@
class ezcWebdavClientRfcTestBackend
{
- public static function getSetup( $testSetName )
- {
+ public static function performSetup( ezcWebdavClientTest $test,
$testSetName )
+ {
+ $test->transport = new ezcWebdavTransportTestMock();
+ $test->transport->options->pathFactory = new ezcWebdavPathFactory(
'http://foo.bar' );
+
switch( $testSetName )
{
case 'propfind_propname':
@@ -11,37 +14,38 @@
case 'supportedlock':
case 'propfind_allprop':
case 'move_collection':
+ case 'delete':
+ return self::getFooBarSetup1( $test );
+ case 'propfind_prop':
+ return self::getFooBarSetup2( $test );
+ case 'proppatch':
+ return self::getFooBarSetup3( $test );
case 'copy_collection':
- case 'delete':
- return self::getFooBarSetup1();
- case 'propfind_prop':
- return self::getFooBarSetup2();
- case 'proppatch':
- return self::getFooBarSetup3();
+ return self::getFooBarSetup4( $test );
case 'copy_success':
case 'copy':
case 'copy_overwrite':
case 'options':
case 'get_collection':
case 'get_resource':
- return self::getIcsUciSetup1();
+ return self::getIcsUciSetup1( $test );
case 'move_resource':
- return self::getIcsUciSetup2();
+ return self::getIcsUciSetup2( $test );
case 'mkcol':
- return self::getServerOrgSetup();
+ return self::getServerOrgSetup( $test );
default:
throw new RuntimeException( "Could not find setup for test set
'$testSetName'." );
}
}
- protected static function getFooBarSetup1()
- {
- $backend = new ezcWebdavMemoryBackend();
- // $backend->options->failForRegexp =
'(container/R2|container/resource3)';
- $backend->options->failForRegexp = '(container)';
- $backend->options->failingOperations =
ezcWebdavMemoryBackendOptions::REQUEST_COPY |
ezcWebdavMemoryBackendOptions::REQUEST_DELETE;
-
- $backend->addContents(
+ protected static function getFooBarSetup1( ezcWebdavClientTest $test )
+ {
+
+ $test->backend = new
ezcWebdavMemoryBackend();
+ $test->backend->options->failForRegexp = '(container/resource3)';
+ $test->backend->options->failingOperations =
ezcWebdavMemoryBackendOptions::REQUEST_DELETE;
+
+ $test->backend->addContents(
array(
'container' => array(
'front.html' => '',
@@ -51,7 +55,7 @@
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavDeadProperty(
'http://www.foo.bar/boxschema/',
@@ -64,7 +68,7 @@
EOT
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavDeadProperty(
'http://www.foo.bar/boxschema/',
@@ -77,25 +81,25 @@
EOT
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavCreationDateProperty(
new DateTime( '1997-12-01T17:42:21-08:00' )
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavDisplayNameProperty(
'Example collection'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavResourceTypeProperty(
'collection'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container',
new ezcWebdavSupportedLockProperty(
array(
@@ -111,7 +115,7 @@
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavDeadProperty(
'http://www.foo.bar/boxschema/',
@@ -124,47 +128,47 @@
EOT
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavCreationDateProperty(
new DateTime( '1997-12-01T18:27:21-08:00' )
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavDisplayNameProperty(
'Example HTML resource'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavGetContentLengthProperty(
'4525'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavGetContentTypeProperty(
'text/html'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavGetEtagProperty(
'zzyzx'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavGetLastModifiedProperty(
new DateTime( 'Monday, 12-Jan-98 09:25:56 GMT' )
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavResourceTypeProperty()
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/container/front.html',
new ezcWebdavSupportedLockProperty(
array(
@@ -180,19 +184,19 @@
)
);
- return $backend;
+ return $test->backend;
}
- protected static function getFooBarSetup2()
- {
- $backend = new ezcWebdavMemoryBackend();
- $backend->addContents(
+ protected static function getFooBarSetup2( ezcWebdavClientTest $test )
+ {
+ $test->backend = new ezcWebdavMemoryBackend();
+ $test->backend->addContents(
array(
'file' => ''
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/file',
new ezcWebdavDeadProperty(
'http://www.foo.bar/boxschema/',
@@ -205,7 +209,7 @@
EOT
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/file',
new ezcWebdavDeadProperty(
'http://www.foo.bar/boxschema/',
@@ -219,19 +223,19 @@
)
);
- return $backend;
+ return $test->backend;
}
- protected static function getFooBarSetup3()
- {
- $backend = new ezcWebdavMemoryBackend();
- $backend->addContents(
+ protected static function getFooBarSetup3( ezcWebdavClientTest $test )
+ {
+ $test->backend = new ezcWebdavMemoryBackend();
+ $test->backend->addContents(
array(
'bar.html' => ''
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/bar.html',
new ezcWebdavDeadProperty(
'http://www.w3.com/standards/z39.50',
@@ -245,20 +249,171 @@
)
);
- return $backend;
- }
-
- protected static function getIcsUciSetup1()
- {
- $backend = new ezcWebdavMemoryBackend();
- $backend->addContents(
+ return $test->backend;
+ }
+
+ protected static function getFooBarSetup4( ezcWebdavClientTest $test )
+ {
+ $test->transport->options->pathFactory = new ezcWebdavPathFactory(
'http://www.foo.bar' );
+
+ $test->backend = new
ezcWebdavMemoryBackend();
+ // $test->backend->options->failForRegexp =
'(container/R2|container/resource3)';
+ $test->backend->options->failForRegexp = '(othercontainer/R2)';
+ $test->backend->options->failingOperations =
ezcWebdavMemoryBackendOptions::REQUEST_COPY;
+
+ $test->backend->addContents(
+ array(
+ 'container' => array(
+ 'front.html' => '',
+ 'R2' => array(),
+ 'resource3' => '',
+ ),
+ )
+ );
+
+ $test->backend->setProperty(
+ '/container',
+ 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
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ 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>Hadrian</R:Name>
+</R:author>
+EOT
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavCreationDateProperty(
+ new DateTime( '1997-12-01T17:42:21-08:00' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavDisplayNameProperty(
+ 'Example collection'
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavResourceTypeProperty(
+ 'collection'
+ )
+ );
+ $test->backend->setProperty(
+ '/container',
+ new ezcWebdavSupportedLockProperty(
+ array(
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_EXCLUSIVE
+ ),
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_SHARED
+ ),
+ )
+ )
+ );
+
+ $test->backend->setProperty(
+ '/container/front.html',
+ 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 B</R:BoxType>
+</R:bigbox>
+EOT
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavCreationDateProperty(
+ new DateTime( '1997-12-01T18:27:21-08:00' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavDisplayNameProperty(
+ 'Example HTML resource'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetContentLengthProperty(
+ '4525'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetContentTypeProperty(
+ 'text/html'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetEtagProperty(
+ 'zzyzx'
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavGetLastModifiedProperty(
+ new DateTime( 'Monday, 12-Jan-98 09:25:56 GMT' )
+ )
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavResourceTypeProperty()
+ );
+ $test->backend->setProperty(
+ '/container/front.html',
+ new ezcWebdavSupportedLockProperty(
+ array(
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_EXCLUSIVE
+ ),
+ new ezcWebdavSupportedLockPropertyLockentry(
+ ezcWebdavLockRequest::TYPE_WRITE,
+ ezcWebdavLockRequest::SCOPE_SHARED
+ ),
+ )
+ )
+ );
+
+ return $test->backend;
+ }
+
+ protected static function getIcsUciSetup1( ezcWebdavClientTest $test )
+ {
+ $test->backend = new ezcWebdavMemoryBackend();
+ $test->backend->addContents(
array(
'~fielding' => array(
'index.html' => '<html><head><title>Foo
Bar</title></head></html>',
),
)
);
- $backend->addContents(
+ $test->backend->addContents(
array(
'users' => array(
'f' => array(
@@ -270,34 +425,34 @@
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/~fielding/index.html',
new ezcWebdavGetContentTypeProperty(
'text/html', 'utf-8'
)
);
- $backend->setProperty(
+ $test->backend->setProperty(
'/~fielding/index.html',
new ezcWebdavGetContentLengthProperty(
'49'
)
);
- return $backend;
- }
-
- protected static function getIcsUciSetup2()
- {
- $backend = new ezcWebdavMemoryBackend();
- $backend->addContents(
+ return $test->backend;
+ }
+
+ protected static function getIcsUciSetup2( ezcWebdavClientTest $test )
+ {
+ $test->backend = new ezcWebdavMemoryBackend();
+ $test->backend->addContents(
array(
'~fielding' => array(
'index.html' => '',
),
)
);
- $backend->addContents(
+ $test->backend->addContents(
array(
'users' => array(
'f' => array(
@@ -308,19 +463,19 @@
)
);
- return $backend;
- }
-
- protected static function getServerOrgSetup()
- {
- $backend = new ezcWebdavMemoryBackend();
- $backend->addContents(
+ return $test->backend;
+ }
+
+ protected static function getServerOrgSetup( ezcWebdavClientTest $test )
+ {
+ $test->backend = new ezcWebdavMemoryBackend();
+ $test->backend->addContents(
array(
'webdisc' => array(),
)
);
- return $backend;
+ return $test->backend;
}
}
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components