2013-10-21 22:46:31 +00:00
< ? php
namespace Sabre\DAV\Locks ;
use Sabre\HTTP ;
use Sabre\DAV ;
require_once 'Sabre/DAV/AbstractServer.php' ;
class PluginTest extends DAV\AbstractServer {
/**
2016-05-11 00:26:44 +00:00
* @ var Plugin
2013-10-21 22:46:31 +00:00
*/
protected $locksPlugin ;
function setUp () {
parent :: setUp ();
$locksBackend = new Backend\File ( SABRE_TEMPDIR . '/locksdb' );
$locksPlugin = new Plugin ( $locksBackend );
$this -> server -> addPlugin ( $locksPlugin );
$this -> locksPlugin = $locksPlugin ;
}
2016-05-11 00:26:44 +00:00
function testGetInfo () {
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertArrayHasKey (
'name' ,
$this -> locksPlugin -> getPluginInfo ()
);
2013-10-21 22:46:31 +00:00
}
2016-05-11 00:26:44 +00:00
function testGetFeatures () {
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( array ( 2 ), $this -> locksPlugin -> getFeatures ());
2013-10-21 22:46:31 +00:00
}
2016-05-11 00:26:44 +00:00
function testGetHTTPMethods () {
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( array ( 'LOCK' , 'UNLOCK' ), $this -> locksPlugin -> getHTTPMethods ( '' ));
2013-10-21 22:46:31 +00:00
}
function testLockNoBody () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> exec ();
$this -> assertEquals ( array (
2016-05-11 00:26:44 +00:00
'X-Sabre-Version' => [ DAV\Version :: VERSION ],
'Content-Type' => [ 'application/xml; charset=utf-8' ],
2013-10-21 22:46:31 +00:00
),
2016-05-11 00:26:44 +00:00
$this -> response -> getHeaders ()
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 400 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
function testLock () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status , 'Got an incorrect status back. Response body: ' . $this -> response -> body );
2013-10-21 22:46:31 +00:00
$body = preg_replace ( " /xmlns(:[A-Za-z0-9_])?=( \" | \ ')DAV:( \" | \ ')/ " , " xmlns \\ 1= \" urn:DAV \" " , $this -> response -> body );
$xml = simplexml_load_string ( $body );
$xml -> registerXPathNamespace ( 'd' , 'urn:DAV' );
$elements = array (
'/d:prop' ,
'/d:prop/d:lockdiscovery' ,
'/d:prop/d:lockdiscovery/d:activelock' ,
'/d:prop/d:lockdiscovery/d:activelock/d:locktype' ,
'/d:prop/d:lockdiscovery/d:activelock/d:lockroot' ,
'/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href' ,
'/d:prop/d:lockdiscovery/d:activelock/d:locktype/d:write' ,
'/d:prop/d:lockdiscovery/d:activelock/d:lockscope' ,
'/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive' ,
'/d:prop/d:lockdiscovery/d:activelock/d:depth' ,
'/d:prop/d:lockdiscovery/d:activelock/d:owner' ,
'/d:prop/d:lockdiscovery/d:activelock/d:timeout' ,
'/d:prop/d:lockdiscovery/d:activelock/d:locktoken' ,
'/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href' ,
);
foreach ( $elements as $elem ) {
$data = $xml -> xpath ( $elem );
$this -> assertEquals ( 1 , count ( $data ), 'We expected 1 match for the xpath expression "' . $elem . '". ' . count ( $data ) . ' were found. Full response body: ' . $this -> response -> body );
}
$depth = $xml -> xpath ( '/d:prop/d:lockdiscovery/d:activelock/d:depth' );
$this -> assertEquals ( 'infinity' ,( string ) $depth [ 0 ]);
$token = $xml -> xpath ( '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href' );
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( $this -> response -> getHeader ( 'Lock-Token' ), '<' . ( string ) $token [ 0 ] . '>' , 'Token in response body didn\'t match token in response header.' );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testDoubleLock () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
$this -> response = new HTTP\ResponseMock ();
$this -> server -> httpResponse = $this -> response ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status , 'Full response: ' . $this -> response -> body );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockRefresh () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$lockToken = $this -> response -> getHeader ( 'Lock-Token' );
2013-10-21 22:46:31 +00:00
$this -> response = new HTTP\ResponseMock ();
$this -> server -> httpResponse = $this -> response ;
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' , [ 'If' => '(' . $lockToken . ')' ]);
2013-10-21 22:46:31 +00:00
$request -> setBody ( '' );
2016-05-11 00:26:44 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertEquals ( 200 , $this -> response -> status , 'We received an incorrect status code. Full response body: ' . $this -> response -> getBody ());
}
/**
* @ depends testLock
*/
function testLockRefreshBadToken () {
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
2016-05-11 00:26:44 +00:00
$this -> server -> exec ();
$lockToken = $this -> response -> getHeader ( 'Lock-Token' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> response = new HTTP\ResponseMock ();
$this -> server -> httpResponse = $this -> response ;
$request = new HTTP\Request ( 'LOCK' , '/test.txt' , [ 'If' => '(' . $lockToken . 'foobar) (<opaquelocktoken:anotherbadtoken>)' ]);
$request -> setBody ( '' );
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> getStatus (), 'We received an incorrect status code. Full response body: ' . $this -> response -> getBody ());
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockNoFile () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/notfound.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testUnlockNoToken () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'UNLOCK' , '/test.txt' );
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ([
'X-Sabre-Version' => [ DAV\Version :: VERSION ],
'Content-Type' => [ 'application/xml; charset=utf-8' ],
],
$this -> response -> getHeaders ()
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 400 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testUnlockBadToken () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'UNLOCK' , '/test.txt' , [ 'Lock-Token' => '<opaquelocktoken:blablabla>' ]);
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ([
'X-Sabre-Version' => [ DAV\Version :: VERSION ],
'Content-Type' => [ 'application/xml; charset=utf-8' ],
],
$this -> response -> getHeaders ()
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 409 , $this -> response -> status , 'Got an incorrect status code. Full response body: ' . $this -> response -> body );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockPutNoToken () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'PUT' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testUnlock () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
2016-05-11 00:26:44 +00:00
$this -> server -> invokeMethod ( $request , $this -> server -> httpResponse );
$lockToken = $this -> server -> httpResponse -> getHeader ( 'Lock-Token' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'UNLOCK' , '/test.txt' , [ 'Lock-Token' => $lockToken ]);
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> httpResponse = new HTTP\ResponseMock ();
2016-05-11 00:26:44 +00:00
$this -> server -> invokeMethod ( $request , $this -> server -> httpResponse );
$this -> assertEquals ( 204 , $this -> server -> httpResponse -> status , 'Got an incorrect status code. Full response body: ' . $this -> response -> body );
$this -> assertEquals ([
'X-Sabre-Version' => [ DAV\Version :: VERSION ],
'Content-Length' => [ '0' ],
],
$this -> server -> httpResponse -> getHeaders ()
2013-10-21 22:46:31 +00:00
);
}
/**
* @ depends testLock
*/
function testUnlockWindowsBug () {
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'LOCK' , '/test.txt' );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
2016-05-11 00:26:44 +00:00
$this -> server -> invokeMethod ( $request , $this -> server -> httpResponse );
$lockToken = $this -> server -> httpResponse -> getHeader ( 'Lock-Token' );
2013-10-21 22:46:31 +00:00
// See Issue 123
$lockToken = trim ( $lockToken , '<>' );
2016-05-11 00:26:44 +00:00
$request = new HTTP\Request ( 'UNLOCK' , '/test.txt' , [ 'Lock-Token' => $lockToken ]);
$this -> server -> httpRequest = $request ;
2013-10-21 22:46:31 +00:00
$this -> server -> httpResponse = new HTTP\ResponseMock ();
2016-05-11 00:26:44 +00:00
$this -> server -> invokeMethod ( $request , $this -> server -> httpResponse );
$this -> assertEquals ( 204 , $this -> server -> httpResponse -> status , 'Got an incorrect status code. Full response body: ' . $this -> response -> body );
$this -> assertEquals ([
'X-Sabre-Version' => [ DAV\Version :: VERSION ],
'Content-Length' => [ '0' ],
],
$this -> server -> httpResponse -> getHeaders ()
2013-10-21 22:46:31 +00:00
);
}
/**
* @ depends testLock
*/
function testLockRetainOwner () {
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ([
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
]);
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner > Evert </ D : owner >
</ D : lockinfo > ' );
2016-05-11 00:26:44 +00:00
$this -> server -> invokeMethod ( $request , $this -> server -> httpResponse );
$lockToken = $this -> server -> httpResponse -> getHeader ( 'Lock-Token' );
2013-10-21 22:46:31 +00:00
$locks = $this -> locksPlugin -> getLocks ( 'test.txt' );
$this -> assertEquals ( 1 , count ( $locks ));
$this -> assertEquals ( 'Evert' , $locks [ 0 ] -> owner );
}
/**
* @ depends testLock
*/
function testLockPutBadToken () {
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'PUT' ,
'HTTP_IF' => '(<opaquelocktoken:token1>)' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
// $this->assertEquals('412 Precondition failed',$this->response->status);
$this -> assertEquals ( 423 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockDeleteParent () {
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir' ,
'REQUEST_METHOD' => 'DELETE' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockDeleteSucceed () {
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'DELETE' ,
2016-05-11 00:26:44 +00:00
'HTTP_IF' => '(' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' ,
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 204 , $this -> response -> status );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockCopyLockSource () {
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'COPY' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status , 'Copy must succeed if only the source is locked, but not the destination' );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockCopyLockDestination () {
$serverVars = array (
'REQUEST_URI' => '/dir/child2.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'COPY' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status , 'Copy must succeed if only the source is locked, but not the destination' );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockMoveLockSourceLocked () {
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'MOVE' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status , 'Copy must succeed if only the source is locked, but not the destination' );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockMoveLockSourceSucceed () {
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'MOVE' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
2016-05-11 00:26:44 +00:00
'HTTP_IF' => '(' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' ,
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status , 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this -> response -> body );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockMoveLockDestination () {
$serverVars = array (
'REQUEST_URI' => '/dir/child2.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'MOVE' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 423 , $this -> response -> status , 'Copy must succeed if only the source is locked, but not the destination' );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockMoveLockParent () {
$serverVars = array (
'REQUEST_URI' => '/dir' ,
'REQUEST_METHOD' => 'LOCK' ,
'HTTP_DEPTH' => 'infinite' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/dir/child.txt' ,
'REQUEST_METHOD' => 'MOVE' ,
'HTTP_DESTINATION' => '/dir/child2.txt' ,
2016-05-11 00:26:44 +00:00
'HTTP_IF' => '</dir> (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' ,
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 201 , $this -> response -> status , 'We locked the parent of both the source and destination, but the move didn\'t succeed.' );
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testLock
*/
function testLockPutGoodToken () {
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'LOCK' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 200 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'PUT' ,
2016-05-11 00:26:44 +00:00
'HTTP_IF' => '(' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' ,
2013-10-21 22:46:31 +00:00
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 204 , $this -> response -> status );
}
/**
* @ depends testLock
*/
function testLockPutUnrelatedToken () {
$request = new HTTP\Request ( 'LOCK' , '/unrelated.txt' );
$request -> setBody ( ' < ? xml version = " 1.0 " ?>
< D : lockinfo xmlns : D = " DAV: " >
< D : lockscope >< D : exclusive /></ D : lockscope >
< D : locktype >< D : write /></ D : locktype >
< D : owner >
< D : href > http :// example . org /~ ejw / contact . html </ D : href >
</ D : owner >
</ D : lockinfo > ' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
$this -> assertEquals ( 201 , $this -> response -> getStatus ());
$request = new HTTP\Request (
'PUT' ,
'/test.txt' ,
[ 'If' => '</unrelated.txt> (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' ]
);
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
$this -> assertEquals ( 'application/xml; charset=utf-8' , $this -> response -> getHeader ( 'Content-Type' ));
$this -> assertTrue ( preg_match ( '/^<opaquelocktoken:(.*)>$/' , $this -> response -> getHeader ( 'Lock-Token' )) === 1 , 'We did not get a valid Locktoken back (' . $this -> response -> getHeader ( 'Lock-Token' ) . ')' );
$this -> assertEquals ( 204 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
function testPutWithIncorrectETag () {
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'PUT' ,
'HTTP_IF' => '(["etag1"])' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 412 , $this -> response -> status );
2013-10-21 22:46:31 +00:00
}
/**
* @ depends testPutWithIncorrectETag
*/
function testPutWithCorrectETag () {
2016-05-11 00:26:44 +00:00
// We need an ETag-enabled file node.
$tree = new DAV\Tree ( new DAV\FSExt\Directory ( SABRE_TEMPDIR ));
2013-10-21 22:46:31 +00:00
$this -> server -> tree = $tree ;
2016-05-11 00:26:44 +00:00
$filename = SABRE_TEMPDIR . '/test.txt' ;
$etag = sha1 (
fileinode ( $filename ) .
filesize ( $filename ) .
filemtime ( $filename )
);
2013-10-21 22:46:31 +00:00
$serverVars = array (
'REQUEST_URI' => '/test.txt' ,
'REQUEST_METHOD' => 'PUT' ,
'HTTP_IF' => '(["' . $etag . '"])' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2013-10-21 22:46:31 +00:00
$request -> setBody ( 'newbody' );
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 204 , $this -> response -> status , 'Incorrect status received. Full response body:' . $this -> response -> body );
2013-10-21 22:46:31 +00:00
}
2014-06-28 20:28:08 +00:00
function testDeleteWithETagOnCollection () {
$serverVars = array (
'REQUEST_URI' => '/dir' ,
'REQUEST_METHOD' => 'DELETE' ,
'HTTP_IF' => '(["etag1"])' ,
);
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( $serverVars );
2014-06-28 20:28:08 +00:00
$this -> server -> httpRequest = $request ;
$this -> server -> exec ();
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 412 , $this -> response -> status );
2014-06-28 20:28:08 +00:00
}
2013-10-21 22:46:31 +00:00
function testGetTimeoutHeader () {
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( array (
2013-10-21 22:46:31 +00:00
'HTTP_TIMEOUT' => 'second-100' ,
));
$this -> server -> httpRequest = $request ;
$this -> assertEquals ( 100 , $this -> locksPlugin -> getTimeoutHeader ());
}
2016-05-11 00:26:44 +00:00
function testGetTimeoutHeaderTwoItems () {
2013-10-21 22:46:31 +00:00
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( array (
'HTTP_TIMEOUT' => 'second-5, infinite' ,
2013-10-21 22:46:31 +00:00
));
$this -> server -> httpRequest = $request ;
2016-05-11 00:26:44 +00:00
$this -> assertEquals ( 5 , $this -> locksPlugin -> getTimeoutHeader ());
2013-10-21 22:46:31 +00:00
}
function testGetTimeoutHeaderInfinite () {
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( array (
'HTTP_TIMEOUT' => 'infinite, second-5' ,
2013-10-21 22:46:31 +00:00
));
$this -> server -> httpRequest = $request ;
$this -> assertEquals ( LockInfo :: TIMEOUT_INFINITE , $this -> locksPlugin -> getTimeoutHeader ());
}
/**
* @ expectedException Sabre\DAV\Exception\BadRequest
*/
function testGetTimeoutHeaderInvalid () {
2016-05-11 00:26:44 +00:00
$request = HTTP\Sapi :: createFromServerArray ( array (
2013-10-21 22:46:31 +00:00
'HTTP_TIMEOUT' => 'yourmom' ,
));
$this -> server -> httpRequest = $request ;
$this -> locksPlugin -> getTimeoutHeader ();
}
}