curlRest('/appdata/1/@self/1', $postData, 'application/json');
$this->assertTrue(empty($ret), "Create app data failed. $ret.");
// Verifies data was written correctly
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'GET');
$retDecoded = json_decode($ret, true);
$this->assertTrue($ret != $retDecoded && $ret != null, "Invalid json string in return: $ret.");
$this->assertTrue(isset($retDecoded['entry']) && isset($retDecoded['entry'][1])
&& isset($retDecoded['entry'][1]['last_poke']) && isset($retDecoded['entry'][1]['pokes'])
&& $retDecoded['entry'][1]['last_poke'] == '2008-06-13T18:30:02Z'
&& $retDecoded['entry'][1]['pokes'] == '4', "Unexpected return value: $ret.");
// Deletes the app data.
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'DELETE');
$this->assertTrue(empty($ret), "Delete app data failed. $ret");
}
public function testAppDataLifeCycleInXml() {
$postData = '
pokes
1
last_poke
2008-02-13T18:30:02Z
';
// Creates or update the app data.
$ret = $this->curlRest('/appdata/1/@self/1', $postData, 'application/xml');
$this->assertTrue(empty($ret), "Create app data failed. $ret");
// Verifies data was written correctly.
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'GET');
$retDecoded = json_decode($ret, true);
$this->assertTrue($ret != $retDecoded && $ret != null, "Invalid json string in return: $ret.");
$this->assertTrue(isset($retDecoded['entry']) && isset($retDecoded['entry'][1])
&& isset($retDecoded['entry'][1]['last_poke']) && isset($retDecoded['entry'][1]['pokes'])
&& $retDecoded['entry'][1]['last_poke'] == '2008-02-13T18:30:02Z'
&& $retDecoded['entry'][1]['pokes'] == '1', "Unexpected return value: $ret.");
// Updates the app data.
$updateData = '
pokes
100
last_poke
2009-02-13T18:30:02Z
';
$ret = $this->curlRest('/appdata/1/@self/1', $updateData, 'application/xml');
$this->assertTrue(empty($ret), "Update app data failed. $ret");
// Verifies data was written correctly.
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'GET');
$retDecoded = json_decode($ret, true);
$this->assertTrue($ret != $retDecoded && $ret != null, "Invalid json string in return: $ret.");
$this->assertTrue(isset($retDecoded['entry']) && isset($retDecoded['entry'][1])
&& isset($retDecoded['entry'][1]['last_poke']) && isset($retDecoded['entry'][1]['pokes'])
&& $retDecoded['entry'][1]['last_poke'] == '2009-02-13T18:30:02Z'
&& $retDecoded['entry'][1]['pokes'] == '100', "Unexpected return value: $ret.");
// Deletes the app data.
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'DELETE');
$this->assertTrue(empty($ret), "Delete app data failed. $ret");
}
public function testAppDataLifeCycleInAtom() {
$postData = '
2
2003-12-14T18:30:02Z
2003-12-14T18:30:02Z
urn:guid:example.org:34KJDCSKJN2HHF0DW20394
urn:guid:example.org:34KJDCSKJN2HHF0DW20394
';
// Creates the app data.
$ret = $this->curlRest('/appdata/1/@self/1', $postData, 'application/atom+xml');
$this->assertTrue(empty($ret), "Create app data failed. $ret");
// Verifies data was written correctly
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'GET');
$retDecoded = json_decode($ret, true);
$this->assertTrue($ret != $retDecoded && $ret != null, "Invalid json string in return: $ret.");
$this->assertTrue(isset($retDecoded['entry']) && isset($retDecoded['entry'][1])
&& isset($retDecoded['entry'][1]['last_poke']) && isset($retDecoded['entry'][1]['pokes'])
&& $retDecoded['entry'][1]['last_poke'] == '2003-12-14T18:30:02Z'
&& $retDecoded['entry'][1]['pokes'] == '2', "Unexpected return value: $ret\n");
// Deletes the app data.
$ret = $this->curlRest('/appdata/1/@self/1?fields=pokes,last_poke', '', 'application/json', 'DELETE');
$this->assertTrue(empty($ret), "Delete app data failed. $ret");
}
}