Author: ts Date: Wed Oct 24 00:26:01 2007 New Revision: 6563 Log: - Added anaolog tests for MOVE than we have for COPY. - Fixed the same Destination header bug in MOVE that was already fixed in COPY.
Modified: trunk/Webdav/src/transport.php trunk/Webdav/tests/transport_test.php Modified: trunk/Webdav/src/transport.php ============================================================================== --- trunk/Webdav/src/transport.php [iso-8859-1] (original) +++ trunk/Webdav/src/transport.php [iso-8859-1] Wed Oct 24 00:26:01 2007 @@ -660,6 +660,11 @@ array( 'Destination', 'Depth', 'Overwrite' ) ); + if ( !isset( $headers['Destination'] ) ) + { + throw new ezcWebdavMissingHeaderException( 'Destination' ); + } + $request = new ezcWebdavMoveRequest( $path, $headers['Destination'] ); $request->setHeaders( $headers ); Modified: trunk/Webdav/tests/transport_test.php ============================================================================== --- trunk/Webdav/tests/transport_test.php [iso-8859-1] (original) +++ trunk/Webdav/tests/transport_test.php [iso-8859-1] Wed Oct 24 00:26:01 2007 @@ -27,6 +27,11 @@ public function parseCopyRequest( $path, $body ) { return parent::parseCopyRequest( $path, $body ); + } + + public function parseMoveRequest( $path, $body ) + { + return parent::parseMoveRequest( $path, $body ); } public function parsePropFindRequest( $path, $body ) @@ -295,6 +300,122 @@ $this->assertTrue( ( $res instanceof ezcWebdavCopyRequest ), + 'Request not parsed correctly: Invalid request class!' + ); + + $this->assertEquals( + array( + 'some property', + 'another property', + ), + $res->propertyBehaviour->keepAlive, + 'Omit property of response object not set correctly.' + ); + } + + public function testParseMoveRequestErrorMissingHeader() + { + $path = '/baz.html'; + $body = 'Foo bar baz'; + + try + { + ezcWebdavServer::getInstance()->transport->parseMoveRequest( $path, $body ); + $this->fail( + 'Exception not thrown on parsing move request without destination header.' + ); + } + catch ( ezcWebdavMissingHeaderException $e ) + { + return; + } + } + + public function testParseMoveRequestErrorBodyInvalidXml() + { + $_SERVER['HTTP_DESTINATION'] = '/foo/bar/baz.html'; + + $path = '/baz.html'; + $body = 'Foo bar baz'; + + try + { + ezcWebdavServer::getInstance()->transport->parseMoveRequest( $path, $body ); + $this->fail( + 'Exception not thrown on parsing move request with invalid XML body.' + ); + } + catch ( ezcWebdavInvalidRequestBodyException $e ) + {} + } + + public function testParseMoveRequestErrorMissingPropertyBehaviourTag() + { + $_SERVER['HTTP_DESTINATION'] = '/foo/bar/baz.html'; + + $path = '/baz.html'; + $body = <<<EOT +<?xml version="1.0" encoding="utf-8" ?> +<d:propertymissbehavior xmlns:d="DAV:"> + <d:omit/> +</d:propertymissbehavior> +EOT; + + try + { + ezcWebdavServer::getInstance()->transport->parseMoveRequest( $path, $body ); + $this->fail( + 'Exception not thrown on parsing move request with invalid XML body.' + ); + } + catch ( ezcWebdavInvalidRequestBodyException $e ) + {} + } + + public function testParseMoveRequestPropertyBehaviourOmitTag() + { + $_SERVER['HTTP_DESTINATION'] = '/foo/bar/baz.html'; + + $path = '/baz.html'; + $body = <<<EOT +<?xml version="1.0" encoding="utf-8" ?> +<d:propertybehavior xmlns:d="DAV:"> + <d:omit/> +</d:propertybehavior> +EOT; + + $res = ezcWebdavServer::getInstance()->transport->parseMoveRequest( $path, $body ); + + $this->assertTrue( + ( $res instanceof ezcWebdavMoveRequest ), + 'Request not parsed correctly: Invalid request class!' + ); + + $this->assertTrue( + $res->propertyBehaviour->omit, + 'Omit property of response object not set correctly.' + ); + } + + public function testParseMoveRequestPropertyBehaviourKeepaliveTagWithHrefContent() + { + $_SERVER['HTTP_DESTINATION'] = '/foo/bar/baz.html'; + + $path = '/baz.html'; + $body = <<<EOT +<?xml version="1.0" encoding="utf-8" ?> +<d:propertybehavior xmlns:d="DAV:"> + <d:keepalive> + <d:href>some property</d:href> + <d:href>another property</d:href> + </d:keepalive> +</d:propertybehavior> +EOT; + + $res = ezcWebdavServer::getInstance()->transport->parseMoveRequest( $path, $body ); + + $this->assertTrue( + ( $res instanceof ezcWebdavMoveRequest ), 'Request not parsed correctly: Invalid request class!' ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components