コード例 #1
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\AccessPolicy::toArray
  */
 public function testToArray()
 {
     // Setup
     $accessPolicy = new AccessPolicy();
     $permission = 'rw';
     $start = '2009-09-28T08:49:37.3942040Z';
     $expiry = '2009-10-28T08:49:37.3942040Z';
     $startDate = new \DateTime($start);
     $expiryDate = new \DateTime($expiry);
     $accessPolicy->setPermission($permission);
     $accessPolicy->setStart($startDate);
     $accessPolicy->setExpiry($expiryDate);
     // Test
     $actual = $accessPolicy->toArray();
     // Assert
     $this->assertEquals($permission, $actual['Permission']);
     $this->assertEquals($start, urldecode($actual['Start']));
     $this->assertEquals($expiry, urldecode($actual['Expiry']));
 }
コード例 #2
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\SignedIdentifier::setAccessPolicy
  */
 public function testSetAccessPolicy()
 {
     // Setup
     $signedIdentifier = new SignedIdentifier();
     $expected = new AccessPolicy();
     $expected->setExpiry(new \DateTime('2009-09-29T08:49:37'));
     $expected->setPermission('rwd');
     $expected->setStart(new \DateTime('2009-09-28T08:49:37'));
     // Test
     $signedIdentifier->setAccessPolicy($expected);
     // Assert
     $this->assertEquals($expected, $signedIdentifier->getAccessPolicy());
     return $signedIdentifier;
 }
コード例 #3
0
 /**
  * Adds new signed modifier
  * 
  * @param string    $id         a unique id for this modifier
  * @param \DateTime $start      The time at which the Shared Access Signature
  * becomes valid. If omitted, start time for this call is assumed to be
  * the time when the Blob service receives the request.
  * @param \DateTime $expiry     The time at which the Shared Access Signature
  * becomes invalid. This field may be omitted if it has been specified as
  * part of a container-level access policy.
  * @param string    $permission The permissions associated with the Shared
  * Access Signature. The user is restricted to operations allowed by the
  * permissions. Valid permissions values are read (r), write (w), delete (d) and
  * list (l).
  * 
  * @return none.
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh508996.aspx
  */
 public function addSignedIdentifier($id, $start, $expiry, $permission)
 {
     Validate::isString($id, 'id');
     Validate::isDate($start);
     Validate::isDate($expiry);
     Validate::isString($permission, 'permission');
     $accessPolicy = new AccessPolicy();
     $accessPolicy->setStart($start);
     $accessPolicy->setExpiry($expiry);
     $accessPolicy->setPermission($permission);
     $signedIdentifier = new SignedIdentifier();
     $signedIdentifier->setId($id);
     $signedIdentifier->setAccessPolicy($accessPolicy);
     $this->_signedIdentifiers[] = $signedIdentifier;
 }