1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAV\Locks; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\HTTP\Request; 6*a1a3b679SAndreas Boehler 7*a1a3b679SAndreas Boehlerclass Plugin2Test extends \Sabre\DAVServerTest { 8*a1a3b679SAndreas Boehler 9*a1a3b679SAndreas Boehler public $setupLocks = true; 10*a1a3b679SAndreas Boehler 11*a1a3b679SAndreas Boehler function setUpTree() { 12*a1a3b679SAndreas Boehler 13*a1a3b679SAndreas Boehler $this->tree = new \Sabre\DAV\FS\Directory(SABRE_TEMPDIR); 14*a1a3b679SAndreas Boehler 15*a1a3b679SAndreas Boehler } 16*a1a3b679SAndreas Boehler 17*a1a3b679SAndreas Boehler function tearDown() { 18*a1a3b679SAndreas Boehler 19*a1a3b679SAndreas Boehler \Sabre\TestUtil::clearTempDir(); 20*a1a3b679SAndreas Boehler 21*a1a3b679SAndreas Boehler } 22*a1a3b679SAndreas Boehler 23*a1a3b679SAndreas Boehler /** 24*a1a3b679SAndreas Boehler * This test first creates a file with LOCK and then deletes it. 25*a1a3b679SAndreas Boehler * 26*a1a3b679SAndreas Boehler * After deleting the file, the lock should no longer be in the lock 27*a1a3b679SAndreas Boehler * backend. 28*a1a3b679SAndreas Boehler * 29*a1a3b679SAndreas Boehler * Reported in ticket #487 30*a1a3b679SAndreas Boehler */ 31*a1a3b679SAndreas Boehler function testUnlockAfterDelete() { 32*a1a3b679SAndreas Boehler 33*a1a3b679SAndreas Boehler $body = '<?xml version="1.0"?> 34*a1a3b679SAndreas Boehler<D:lockinfo xmlns:D="DAV:"> 35*a1a3b679SAndreas Boehler <D:lockscope><D:exclusive/></D:lockscope> 36*a1a3b679SAndreas Boehler <D:locktype><D:write/></D:locktype> 37*a1a3b679SAndreas Boehler</D:lockinfo>'; 38*a1a3b679SAndreas Boehler 39*a1a3b679SAndreas Boehler $request = new Request( 40*a1a3b679SAndreas Boehler 'LOCK', 41*a1a3b679SAndreas Boehler '/file.txt', 42*a1a3b679SAndreas Boehler [], 43*a1a3b679SAndreas Boehler $body 44*a1a3b679SAndreas Boehler ); 45*a1a3b679SAndreas Boehler $response = $this->request($request); 46*a1a3b679SAndreas Boehler $this->assertEquals(201, $response->getStatus(), $response->getBodyAsString()); 47*a1a3b679SAndreas Boehler 48*a1a3b679SAndreas Boehler $this->assertEquals( 49*a1a3b679SAndreas Boehler 1, 50*a1a3b679SAndreas Boehler count($this->locksBackend->getLocks('file.txt', true)) 51*a1a3b679SAndreas Boehler ); 52*a1a3b679SAndreas Boehler 53*a1a3b679SAndreas Boehler $request = new Request( 54*a1a3b679SAndreas Boehler 'DELETE', 55*a1a3b679SAndreas Boehler '/file.txt', 56*a1a3b679SAndreas Boehler [ 57*a1a3b679SAndreas Boehler 'If' => '(' . $response->getHeader('Lock-Token') . ')', 58*a1a3b679SAndreas Boehler ] 59*a1a3b679SAndreas Boehler ); 60*a1a3b679SAndreas Boehler $response = $this->request($request); 61*a1a3b679SAndreas Boehler $this->assertEquals(204, $response->getStatus(), $response->getBodyAsString()); 62*a1a3b679SAndreas Boehler 63*a1a3b679SAndreas Boehler $this->assertEquals( 64*a1a3b679SAndreas Boehler 0, 65*a1a3b679SAndreas Boehler count($this->locksBackend->getLocks('file.txt', true)) 66*a1a3b679SAndreas Boehler ); 67*a1a3b679SAndreas Boehler } 68*a1a3b679SAndreas Boehler 69*a1a3b679SAndreas Boehler} 70