Author: kn
Date: Tue Dec 4 11:33:51 2007
New Revision: 6912
Log:
- Fixed tests to work with all combinations of mime type detection extensions
Modified:
trunk/Webdav/src/backends/file.php
trunk/Webdav/tests/backend_file_test.php
Modified: trunk/Webdav/src/backends/file.php
==============================================================================
--- trunk/Webdav/src/backends/file.php [iso-8859-1] (original)
+++ trunk/Webdav/src/backends/file.php [iso-8859-1] Tue Dec 4 11:33:51 2007
@@ -213,7 +213,10 @@
{
$fInfo = new fInfo( FILEINFO_MIME );
$mimeType = $fInfo->file( $this->root . $resource );
- $fInfo->close();
+
+ // The documentation tells to do this, but it does not work with a
+ // current version of pecl/fileinfo
+ // $fInfo->close();
return $mimeType;
}
Modified: trunk/Webdav/tests/backend_file_test.php
==============================================================================
--- trunk/Webdav/tests/backend_file_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/backend_file_test.php [iso-8859-1] Tue Dec 4 11:33:51
2007
@@ -1302,8 +1302,14 @@
$this->compareResponse( __FUNCTION__, $response );
}
- public function testPropMimeTypeOnResource()
- {
+ public function testPropMimeTypeOnResourceNoExt()
+ {
+ if ( function_exists( 'finfo_file' ) ||
+ function_exists( 'mime_content_type' ) )
+ {
+ $this->markTestSkipped( 'Test is run only, when no mime type
detection is available.' );
+ }
+
$backend = new ezcWebdavFileBackend( $this->tempDir . 'backend/' );
$newProperties = new ezcWebdavFlaggedPropertyStorage();
@@ -1329,7 +1335,116 @@
$responseProperty = new ezcWebdavBasicPropertyStorage();
$responseProperty->attach(
+ new ezcWebdavGetContentTypeProperty( 'text/xml' )
+ );
+
+ $responseProperty->rewind();
+ $expectedResponse = new ezcWebdavMultistatusResponse(
+ new ezcWebdavPropFindResponse(
+ new ezcWebdavResource( '/resource' ),
+ new ezcWebdavPropStatResponse(
+ $responseProperty
+ )
+ )
+ );
+
+ $this->assertEquals(
+ $expectedResponse,
+ $response,
+ 'Expected response does not match real response.',
+ 0,
+ 20
+ );
+ }
+
+ public function testPropMimeTypeOnResourceMimeMagicExt()
+ {
+ if ( function_exists( 'finfo_file' ) ||
+ !function_exists( 'mime_content_type' ) )
+ {
+ $this->markTestSkipped( 'Test is run only, when only mime magic
extenstion is available.' );
+ }
+
+ $backend = new ezcWebdavFileBackend( $this->tempDir . 'backend/' );
+
+ $newProperties = new ezcWebdavFlaggedPropertyStorage();
+ $newProperties->attach(
+ new ezcWebdavGetContentTypeProperty( 'text/xml' ),
+ ezcWebdavPropPatchRequest::SET
+ );
+
+ $request = new ezcWebdavPropPatchRequest( '/resource' );
+ $request->updates = $newProperties;
+ $request->validateHeaders();
+ $response = $backend->proppatch( $request );
+
+ $requestedProperties = new ezcWebdavBasicPropertyStorage();
+ $requestedProperties->attach(
+ new ezcWebdavGetContentTypeProperty()
+ );
+
+ $request = new ezcWebdavPropFindRequest( '/resource' );
+ $request->prop = $requestedProperties;
+ $request->validateHeaders();
+ $response = $backend->propfind( $request );
+
+ $responseProperty = new ezcWebdavBasicPropertyStorage();
+ $responseProperty->attach(
new ezcWebdavGetContentTypeProperty( 'text/plain' )
+ );
+
+ $responseProperty->rewind();
+ $expectedResponse = new ezcWebdavMultistatusResponse(
+ new ezcWebdavPropFindResponse(
+ new ezcWebdavResource( '/resource' ),
+ new ezcWebdavPropStatResponse(
+ $responseProperty
+ )
+ )
+ );
+
+ $this->assertEquals(
+ $expectedResponse,
+ $response,
+ 'Expected response does not match real response.',
+ 0,
+ 20
+ );
+ }
+
+ public function testPropMimeTypeOnResourcePeclFileInfo()
+ {
+ if ( !function_exists( 'finfo_file' ) )
+ {
+ $this->markTestSkipped( 'Test is run only, when pecl/fileinfo
extenstion is available.' );
+ }
+
+ $backend = new ezcWebdavFileBackend( $this->tempDir . 'backend/' );
+
+ $newProperties = new ezcWebdavFlaggedPropertyStorage();
+ $newProperties->attach(
+ new ezcWebdavGetContentTypeProperty( 'text/xml' ),
+ ezcWebdavPropPatchRequest::SET
+ );
+
+ $request = new ezcWebdavPropPatchRequest( '/resource' );
+ $request->updates = $newProperties;
+ $request->validateHeaders();
+ $response = $backend->proppatch( $request );
+
+ $requestedProperties = new ezcWebdavBasicPropertyStorage();
+ $requestedProperties->attach(
+ new ezcWebdavGetContentTypeProperty()
+ );
+
+ $request = new ezcWebdavPropFindRequest( '/resource' );
+ $request->prop = $requestedProperties;
+ $request->validateHeaders();
+ $response = $backend->propfind( $request );
+
+ $responseProperty = new ezcWebdavBasicPropertyStorage();
+ $responseProperty->attach(
+ new ezcWebdavGetContentTypeProperty( 'text/plain;
charset=us-ascii' )
);
$responseProperty->rewind();
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components