"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/Sabre/DAV/Locks/PluginTest.php" between
dav-4.0.2.tar.gz and dav-4.0.3.tar.gz

About: sabre/dav is a WebDAV framework for PHP allowing to create WebDAV, CalDAV and CardDAV servers.

PluginTest.php  (dav-4.0.2):PluginTest.php  (dav-4.0.3)
skipping to change at line 80 skipping to change at line 80
<D:href>http://example.org/~ejw/contact.html</D:href> <D:href>http://example.org/~ejw/contact.html</D:href>
</D:owner> </D:owner>
</D:lockinfo>'); </D:lockinfo>');
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
$this->assertEquals('application/xml; charset=utf-8', $this->response->g etHeader('Content-Type')); $this->assertEquals('application/xml; charset=utf-8', $this->response->g etHeader('Content-Type'));
$this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this-> response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$t his->response->getHeader('Lock-Token').')'); $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this-> response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$t his->response->getHeader('Lock-Token').')');
$this->assertEquals(200, $this->response->status, 'Got an incorrect stat us back. Response body: '.$this->response->body); $this->assertEquals(200, $this->response->status, 'Got an incorrect stat us back. Response body: '.$this->response->getBodyAsString());
$body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmln s\\1="urn:DAV"', $this->response->body); $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmln s\\1="urn:DAV"', $this->response->getBodyAsString());
$xml = simplexml_load_string($body); $xml = simplexml_load_string($body);
$xml->registerXPathNamespace('d', 'urn:DAV'); $xml->registerXPathNamespace('d', 'urn:DAV');
$elements = [ $elements = [
'/d:prop', '/d:prop',
'/d:prop/d:lockdiscovery', '/d:prop/d:lockdiscovery',
'/d:prop/d:lockdiscovery/d:activelock', '/d:prop/d:lockdiscovery/d:activelock',
'/d:prop/d:lockdiscovery/d:activelock/d:locktype', '/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:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href', '/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href',
skipping to change at line 105 skipping to change at line 105
'/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive', '/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:depth',
'/d:prop/d:lockdiscovery/d:activelock/d:owner', '/d:prop/d:lockdiscovery/d:activelock/d:owner',
'/d:prop/d:lockdiscovery/d:activelock/d:timeout', '/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:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href', '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href',
]; ];
foreach ($elements as $elem) { foreach ($elements as $elem) {
$data = $xml->xpath($elem); $data = $xml->xpath($elem);
$this->assertEquals(1, count($data), 'We expected 1 match for the xp ath expression "'.$elem.'". '.count($data).' were found. Full response body: '.$ this->response->body); $this->assertEquals(1, count($data), 'We expected 1 match for the xp ath expression "'.$elem.'". '.count($data).' were found. Full response body: '.$ this->response->getBodyAsString());
} }
$depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth');
$this->assertEquals('infinity', (string) $depth[0]); $this->assertEquals('infinity', (string) $depth[0]);
$token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d :href'); $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d :href');
$this->assertEquals($this->response->getHeader('Lock-Token'), '<'.(strin g) $token[0].'>', 'Token in response body didn\'t match token in response header .'); $this->assertEquals($this->response->getHeader('Lock-Token'), '<'.(strin g) $token[0].'>', 'Token in response body didn\'t match token in response header .');
} }
/** /**
skipping to change at line 140 skipping to change at line 140
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
$this->response = new HTTP\ResponseMock(); $this->response = new HTTP\ResponseMock();
$this->server->httpResponse = $this->response; $this->server->httpResponse = $this->response;
$this->server->exec(); $this->server->exec();
$this->assertEquals('application/xml; charset=utf-8', $this->response->g etHeader('Content-Type')); $this->assertEquals('application/xml; charset=utf-8', $this->response->g etHeader('Content-Type'));
$this->assertEquals(423, $this->response->status, 'Full response: '.$thi s->response->body); $this->assertEquals(423, $this->response->status, 'Full response: '.$thi s->response->getBodyAsString());
} }
/** /**
* @depends testLock * @depends testLock
*/ */
public function testLockRefresh() public function testLockRefresh()
{ {
$request = new HTTP\Request('LOCK', '/test.txt'); $request = new HTTP\Request('LOCK', '/test.txt');
$request->setBody('<?xml version="1.0"?> $request->setBody('<?xml version="1.0"?>
<D:lockinfo xmlns:D="DAV:"> <D:lockinfo xmlns:D="DAV:">
skipping to change at line 270 skipping to change at line 270
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
$this->assertEquals([ $this->assertEquals([
'X-Sabre-Version' => [DAV\Version::VERSION], 'X-Sabre-Version' => [DAV\Version::VERSION],
'Content-Type' => ['application/xml; charset=utf-8'], 'Content-Type' => ['application/xml; charset=utf-8'],
], ],
$this->response->getHeaders() $this->response->getHeaders()
); );
$this->assertEquals(409, $this->response->status, 'Got an incorrect stat us code. Full response body: '.$this->response->body); $this->assertEquals(409, $this->response->status, 'Got an incorrect stat us code. Full response body: '.$this->response->getBodyAsString());
} }
/** /**
* @depends testLock * @depends testLock
*/ */
public function testLockPutNoToken() public function testLockPutNoToken()
{ {
$request = new HTTP\Request('LOCK', '/test.txt'); $request = new HTTP\Request('LOCK', '/test.txt');
$request->setBody('<?xml version="1.0"?> $request->setBody('<?xml version="1.0"?>
<D:lockinfo xmlns:D="DAV:"> <D:lockinfo xmlns:D="DAV:">
skipping to change at line 332 skipping to change at line 332
</D:lockinfo>'); </D:lockinfo>');
$this->server->invokeMethod($request, $this->server->httpResponse); $this->server->invokeMethod($request, $this->server->httpResponse);
$lockToken = $this->server->httpResponse->getHeader('Lock-Token'); $lockToken = $this->server->httpResponse->getHeader('Lock-Token');
$request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $loc kToken]); $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $loc kToken]);
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->httpResponse = new HTTP\ResponseMock(); $this->server->httpResponse = new HTTP\ResponseMock();
$this->server->invokeMethod($request, $this->server->httpResponse); $this->server->invokeMethod($request, $this->server->httpResponse);
$this->assertEquals(204, $this->server->httpResponse->status, 'Got an in correct status code. Full response body: '.$this->response->body); $this->assertEquals(204, $this->server->httpResponse->status, 'Got an in correct status code. Full response body: '.$this->response->getBodyAsString());
$this->assertEquals([ $this->assertEquals([
'X-Sabre-Version' => [DAV\Version::VERSION], 'X-Sabre-Version' => [DAV\Version::VERSION],
'Content-Length' => ['0'], 'Content-Length' => ['0'],
], ],
$this->server->httpResponse->getHeaders() $this->server->httpResponse->getHeaders()
); );
} }
/** /**
* @depends testLock * @depends testLock
skipping to change at line 369 skipping to change at line 369
$lockToken = $this->server->httpResponse->getHeader('Lock-Token'); $lockToken = $this->server->httpResponse->getHeader('Lock-Token');
// See Issue 123 // See Issue 123
$lockToken = trim($lockToken, '<>'); $lockToken = trim($lockToken, '<>');
$request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $loc kToken]); $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $loc kToken]);
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->httpResponse = new HTTP\ResponseMock(); $this->server->httpResponse = new HTTP\ResponseMock();
$this->server->invokeMethod($request, $this->server->httpResponse); $this->server->invokeMethod($request, $this->server->httpResponse);
$this->assertEquals(204, $this->server->httpResponse->status, 'Got an in correct status code. Full response body: '.$this->response->body); $this->assertEquals(204, $this->server->httpResponse->status, 'Got an in correct status code. Full response body: '.$this->response->getBodyAsString());
$this->assertEquals([ $this->assertEquals([
'X-Sabre-Version' => [DAV\Version::VERSION], 'X-Sabre-Version' => [DAV\Version::VERSION],
'Content-Length' => ['0'], 'Content-Length' => ['0'],
], ],
$this->server->httpResponse->getHeaders() $this->server->httpResponse->getHeaders()
); );
} }
/** /**
* @depends testLock * @depends testLock
skipping to change at line 632 skipping to change at line 632
$this->assertEquals(200, $this->response->status); $this->assertEquals(200, $this->response->status);
$request = new HTTP\Request('MOVE', '/dir/child.txt', [ $request = new HTTP\Request('MOVE', '/dir/child.txt', [
'Destination' => '/dir/child2.txt', 'Destination' => '/dir/child2.txt',
'If' => '('.$this->response->getHeader('Lock-Token').')', 'If' => '('.$this->response->getHeader('Lock-Token').')',
]); ]);
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
$this->assertEquals(201, $this->response->status, 'A valid lock-token wa s provided for the source, so this MOVE operation must succeed. Full response bo dy: '.$this->response->body); $this->assertEquals(201, $this->response->status, 'A valid lock-token wa s provided for the source, so this MOVE operation must succeed. Full response bo dy: '.$this->response->getBodyAsString());
} }
/** /**
* @depends testLock * @depends testLock
*/ */
public function testLockMoveLockDestination() public function testLockMoveLockDestination()
{ {
$request = new HTTP\Request('LOCK', '/dir/child2.txt'); $request = new HTTP\Request('LOCK', '/dir/child2.txt');
$request->setBody('<?xml version="1.0"?> $request->setBody('<?xml version="1.0"?>
<D:lockinfo xmlns:D="DAV:"> <D:lockinfo xmlns:D="DAV:">
skipping to change at line 812 skipping to change at line 812
filemtime($filename) filemtime($filename)
); );
$request = new HTTP\Request('PUT', '/test.txt', [ $request = new HTTP\Request('PUT', '/test.txt', [
'If' => '(["'.$etag.'"])', 'If' => '(["'.$etag.'"])',
]); ]);
$request->setBody('newbody'); $request->setBody('newbody');
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
$this->assertEquals(204, $this->response->status, 'Incorrect status rece ived. Full response body:'.$this->response->body); $this->assertEquals(204, $this->response->status, 'Incorrect status rece ived. Full response body:'.$this->response->getBodyAsString());
} }
public function testDeleteWithETagOnCollection() public function testDeleteWithETagOnCollection()
{ {
$request = new HTTP\Request('DELETE', '/dir', [ $request = new HTTP\Request('DELETE', '/dir', [
'If' => '(["etag1"])', 'If' => '(["etag1"])',
]); ]);
$this->server->httpRequest = $request; $this->server->httpRequest = $request;
$this->server->exec(); $this->server->exec();
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)