-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Description
While doing some working I noticed something weird in one of the tests.
It seems to be caused by pollution of the mutable response object.
function testLockPutNoToken() {
$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>');
$this->server->httpRequest = $request;
$this->server->start();
$response = $this->server->httpResponse->getResponse();
$this->assertEquals('application/xml; charset=utf-8', $response->getHeaderLine('Content-Type'));
$this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $response->getHeaderLine('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->getResponse()->getHeaderLine('Lock-Token') . ')');
$this->assertEquals(200, $response->getStatusCode());
$request = new HTTP\Request('PUT', '/test.txt');
$request->setBody('newbody');
$this->server->httpRequest = $request;
$this->server->httpResponse->reset();
$this->server->start();
$response = $this->server->httpResponse->getResponse();
$this->assertEquals(423, $response->getStatusCode());
$this->assertEmpty($response->getHeaders(), print_r($response->getHeaders(), true));
$this->assertEquals('application/xml; charset=utf-8', $response->getHeaderLine('Content-Type'));
$this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $response->getHeaderLine('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $response->getHeaderLine('Lock-Token') . ')');
}
Note this is code contains a few changes from the current master but it should be similar enough to be understandable.
The second request does not contain a lock token, but it expects a Lock-Token header in the response to a PUT request.
That seems weird to me (I suspect it currently only succeeds because the current implementation keeps mutating the same response object which retains the "old" headers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels