Пример #1
0
 public function setUp()
 {
     $properties = new PropertySet();
     $properties['D:displayname'] = 'Example collection';
     $properties->add(new DateTimeProperty('D:creationdate', '1997-12-01T17:42:21-08:00'));
     $properties->add(new ResourceType('collection'));
     $lockCapabilities = new SupportedLock(array('write' => array('exclusive', 'shared')));
     $properties->add($lockCapabilities);
     $this->collection = new Resource('http://www.foo.bar/container/', $properties);
     $resourceProps = new PropertySet();
     $resourceProps['D:displayname'] = 'Example HTML resource';
     $resourceProps['D:getcontentlength'] = 4525;
     $resourceProps['D:getcontenttype'] = 'text/html';
     $resourceProps['D:getcontentlanguage'] = 'en';
     $resourceProps['D:getetag'] = 'zzyzx';
     $resourceProps->add(new DateTimeProperty('D:creationdate', '1997-12-01T18:27:21-08:00'));
     $resourceProps->add(new DateTimeProperty('D:getlastmodified', 'Monday, 12-Jan-98 09:25:56 GMT'));
     $resourceProps->add(new ResourceType());
     $resourceProps->add(new SupportedLock(array('write' => array('exclusive', 'shared'))));
     $this->lock = new Lock();
     $this->lock->setDepth(-1);
     $this->lock->setTimeout(604800);
     $this->lock->setOwner('http://www.ics.uci.edu/~ejw/contact.html');
     $this->lock->setToken('opaquelocktoken:e71d4fae-5dec-22d6-fea5-00a0c91e6be4');
     $resourceProps->add(new LockDiscovery(array($this->lock)));
     $this->resource = new Resource('http://www.foo.bar/container/front.html', $resourceProps);
 }
Пример #2
0
 public function setUp()
 {
     $lockOne = new Lock('shared');
     $lockOne->setToken('opaquelocktoken:e71df4fae-5dec-22d6-fea5-00a0c91e6be4');
     $lockTwo = new Lock('exclusive');
     $lockTwo->setToken('opaquelocktoken:e71d4fae-5dec-22df-fea5-00a0c93bd5eb1');
     $this->property = new LockDiscovery(array($lockOne, $lockTwo));
 }
Пример #3
0
 /**
  * Refresh an existing lock by resetting its timeout.
  *
  * Performs a <tt>LOCK</tt> request as defined in the
  * {@link http://tools.ietf.org/html/rfc4918#section-9.10.2 Section 9.10.2 of RFC-4918}.
  *
  * Note that the timeout value may be suggested when refreshing the lock, but that the server
  * ultimately chooses the timeout value.
  *
  * @param string $uri
  *            Resource URI
  * @param string $lockToken
  *            The lock token identifying the lock to be refreshed
  * @param int $timeout
  *            Number of seconds remaining until lock expiration
  *            
  * @return Lock Returns the refreshed lock on success, or <tt>null</tt> on failure
  */
 public function refreshLock($uri, $lockToken, $timeout = null)
 {
     $headers = array('If' => "(<{$lockToken}>)");
     if ($timeout) {
         $headers['Timeout'] = (string) TimeoutHeader::parse($timeout);
     }
     $request = $this->createRequest('LOCK', $uri, $headers);
     $response = $this->doRequest($request);
     return $response->isSuccessful() ? Lock::parse($this, $response->getBody()) : null;
 }
Пример #4
0
 public function testReleaseLock()
 {
     $lock = new Lock();
     $lock->setToken('opaquelocktoken:e71d4fae-5dec-22d6-fea5-00a0c91e6be4');
     $this->client->expects($this->once())->method('createLock')->will($this->returnValue($lock));
     $fd = fopen('webdav://www.foo.bar/front.html', 'w');
     flock($fd, LOCK_EX);
     $this->client->expects($this->once())->method('releaseLock')->with($this->equalTo('http://www.foo.bar/front.html'), $this->equalTo($lock->getToken()))->will($this->returnValue(true));
     $result = flock($fd, LOCK_UN);
     $this->assertTrue($result);
 }
Пример #5
0
 public function testFromLockInfoXml()
 {
     $dom = new \DOMDocument();
     $dom->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <D:lockinfo xmlns:D="DAV:">
           <D:locktype><D:write/></D:locktype>
           <D:lockscope><D:exclusive/></D:lockscope>
           <D:owner>
             <D:href>http://example.org/~ejw/contact.html</D:href>
           </D:owner>
         </D:lockinfo>');
     $lock = Lock::fromXml($dom->documentElement);
     $this->assertEquals('write', $lock->getType());
     $this->assertEquals('exclusive', $lock->getScope());
     $this->assertEquals('http://example.org/~ejw/contact.html', $lock->getOwner());
     $this->assertEmpty($lock->getToken());
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public static function fromXml(\DOMElement $element, array $xmlNamespaces = array())
 {
     $locks = array();
     foreach ($element->getElementsByTagNameNS('DAV:', 'activelock') as $xActiveLock) {
         $locks[] = Lock::fromXml($xActiveLock);
     }
     return new self($locks);
 }