Esempio n. 1
0
 /**
  * Test deleting user metadata
  */
 public function testDeleteUserMetadataInKeypool()
 {
     if ($this->atmosMajorMinor < 2.1) {
         $this->markTestSkipped("Requires Atmos >= 2.1.0");
         return;
     }
     $kp = new Keypool($this->TEST_KEYPOOL, $this->randomKey());
     // Create an object with metadata
     $mlist = new MetadataList();
     $listable = new Metadata('listable', 'foo', true);
     $unlistable = new Metadata('unlistable', 'bar', false);
     $listable2 = new Metadata('listable2', 'foo2 foo2', true);
     $unlistable2 = new Metadata('unlistable2', 'bar2 bar2', false);
     $mlist->addMetadata($listable);
     $mlist->addMetadata($unlistable);
     $mlist->addMetadata($listable2);
     $mlist->addMetadata($unlistable2);
     $id = $this->esu->createObjectInKeypool($kp, null, $mlist, null, null);
     PHPUnit_Framework_Assert::assertNotNull($id, 'null ID returned');
     $this->cleanup[] = $kp;
     // Delete a couple of the metadata entries
     $mtags = new MetadataTags();
     $mtags->addTag(new MetadataTag('listable2', true));
     $mtags->addTag(new MetadataTag('unlistable2', false));
     $this->esu->deleteUserMetadata($kp, $mtags);
     // Read back the metadata for the object and ensure the deleted
     // entries don't exist
     $meta = $this->esu->getUserMetadata($kp);
     PHPUnit_Framework_Assert::assertEquals('foo', $meta->getMetadata('listable')->getValue(), "value of 'listable' wrong");
     PHPUnit_Framework_Assert::assertNull($meta->getMetadata('listable2'), "metadata 'listable2' should have been deleted");
     PHPUnit_Framework_Assert::assertEquals('bar', $meta->getMetadata('unlistable')->getValue(), "value of 'unlistable' wrong");
     PHPUnit_Framework_Assert::assertNull($meta->getMetadata('unlistable2'), "metadata 'unlistable2' should have been deleted");
 }
Esempio n. 2
0
 /**
  * Parse a metadata response header and add Metadata objects to the
  * given MetadataList
  * @param MetadataList $meta a reference to the MetadataList to append
  * @param string $header the response header to parse
  * @param boolean $listable whether to mark the Metadata objects as
  * listable or not
  */
 private function readMetadata(&$meta, $header, $listable, $utf8)
 {
     if ($header == null) {
         return;
     }
     $attrs = explode(', ', $header);
     foreach ($attrs as $attr) {
         $nvpair = explode('=', $attr, 2);
         $name = ltrim($nvpair[0], ' ');
         $value = $nvpair[1];
         if ($utf8) {
             $name = urldecode($name);
             $value = urldecode($value);
         }
         $m = new Metadata($name, $value, $listable);
         $meta->addMetadata($m);
     }
 }