public function testCreatorSummaryAtom() { $xml = API::createItem("book", array("creators" => array(array("creatorType" => "author", "name" => "Test"))), $this, 'atom'); $data = API::parseDataFromAtomEntry($xml); $itemKey = $data['key']; $json = json_decode($data['content'], true); $creatorSummary = (string) array_shift($xml->xpath('//atom:entry/zapi:creatorSummary')); $this->assertEquals("Test", $creatorSummary); $json['creators'][] = array("creatorType" => "author", "firstName" => "Alice", "lastName" => "Foo"); $response = API::userPut(self::$config['userID'], "items/{$itemKey}", json_encode($json)); $this->assert204($response); $xml = API::getItemXML($itemKey); $creatorSummary = (string) array_shift($xml->xpath('//atom:entry/zapi:creatorSummary')); $this->assertEquals("Test and Foo", $creatorSummary); $data = API::parseDataFromAtomEntry($xml); $json = json_decode($data['content'], true); $json['creators'][] = array("creatorType" => "author", "firstName" => "Bob", "lastName" => "Bar"); $response = API::userPut(self::$config['userID'], "items/{$itemKey}", json_encode($json)); $this->assert204($response); $xml = API::getItemXML($itemKey); $creatorSummary = (string) array_shift($xml->xpath('//atom:entry/zapi:creatorSummary')); $this->assertEquals("Test et al.", $creatorSummary); }
public function testEditAttachmentAtomUpdatedTimestamp() { $xml = API::createAttachmentItem("linked_file", [], false, $this, 'atom'); $data = API::parseDataFromAtomEntry($xml); $atomUpdated = (string) array_shift($xml->xpath('//atom:entry/atom:updated')); $json = json_decode($data['content'], true); $json['note'] = "Test"; sleep(1); $response = API::userPut( self::$config['userID'], "items/{$data['key']}", json_encode($json), array("If-Unmodified-Since-Version: " . $data['version']) ); $this->assert204($response); $xml = API::getItemXML($data['key']); $atomUpdated2 = (string) array_shift($xml->xpath('//atom:entry/atom:updated')); $this->assertNotEquals($atomUpdated2, $atomUpdated); }