示例#1
0
 public function testUserGroupsOwned()
 {
     $response = API::get("users/" . self::$config['userID'] . "/groups?content=json" . "&key=" . self::$config['apiKey']);
     $this->assert200($response);
     $this->assertNumResults(self::$config['numOwnedGroups'], $response);
     $this->assertTotalResults(self::$config['numOwnedGroups'], $response);
 }
示例#2
0
 public function testComputerProgramVersion()
 {
     $response = API::get("items/new?itemType=computerProgram");
     $this->assert200($response);
     $json = json_decode($response->getBody());
     $this->assertObjectHasAttribute('versionNumber', $json);
     $this->assertObjectNotHasAttribute('version', $json);
     $response = API::get("itemTypeFields?itemType=computerProgram");
     $this->assert200($response);
     $json = json_decode($response->getBody());
     $fields = array_map(function ($val) {
         return $val->field;
     }, $json);
     $this->assertContains('versionNumber', $fields);
     $this->assertNotContains('version', $fields);
 }
示例#3
0
 public function testGetKey()
 {
     API::useAPIKey("");
     $response = API::get('keys/' . self::$config['apiKey']);
     $this->assert200($response);
     $json = API::getJSONFromResponse($response);
     $this->assertEquals(self::$config['apiKey'], $json['key']);
     $this->assertEquals(self::$config['userID'], $json['userID']);
     $this->arrayHasKey("user", $json['access']);
     $this->arrayHasKey("groups", $json['access']);
     $this->assertTrue($json['access']['user']['library']);
     $this->assertTrue($json['access']['user']['files']);
     $this->assertTrue($json['access']['user']['notes']);
     $this->assertTrue($json['access']['user']['write']);
     $this->assertTrue($json['access']['groups']['all']['library']);
     $this->assertTrue($json['access']['groups']['all']['write']);
 }
示例#4
0
	/**
	 * @depends testNewEmptyBookItem
	 */
	public function testNewAttachmentItemModTimeOnLinkedURL($json) {
		$parentKey = $json['key'];
		
		$response = API::get("items/new?itemType=attachment&linkMode=linked_url");
		$json = json_decode($response->getBody());
		$json->parentItem = $parentKey;
		
		$json->mtime = "1332807793000";
		$response = API::userPost(
			self::$config['userID'],
			"items",
			json_encode([$json]),
			array("Content-Type: application/json")
		);
		$this->assert400ForObject($response, "'mtime' is valid only for imported attachment items");
	}
示例#5
0
 public function testNoSearchesSupport()
 {
     $response = API::get("users/" . self::$config['userID'] . "/publications/searches");
     $this->assert404($response);
 }
示例#6
0
 public function test404Compression()
 {
     $response = API::get("invalidurl");
     $this->assertHTTPStatus(404, $response);
     $this->assertCompression($response);
 }