/** * 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"); }
/** * Parses a metadata tag response header and appends to the given * MetadataTags object. * @param MetadataTags $tags the MetadataTags to append to * @param string $header the response header to parse * @param boolean $listable the value of the listable flag on the created * tags */ private function readTags(&$tags, $header, $listable) { if ($header == null) { return; } $attrs = explode(',', $header); foreach ($attrs as $attr) { $attr = ltrim($attr, ' '); $tags->addTag(new MetadataTag($attr, $listable)); $this->trace('Created tag: >' . $attr . '<'); } }