示例#1
0
 public function testValidKeys()
 {
     $keys = array('id' => 1, 'name' => 'test', 'description' => 'test', 'details' => 'test', 'createTime' => '2011-02-17T18:47:16', 'owner' => array('id' => 1, 'name' => 'test', 'userName' => 'test', 'email' => 'test@test'));
     $this->assertTrue(Project::validKeys($keys));
     $keys = array('id' => null, 'test' => null);
     $this->assertFalse(Project::validKeys($keys));
     $keys = array('id' => 1, 'owner' => array('id' => 1, 'test' => 'test'));
     $this->assertFalse(Project::validKeys($keys));
 }
示例#2
0
 /**
  * Modifies a single project’s metadata.
  * 
  * @param  integer $id
  * @param  array $data (valid keys are: 'name', 'description', 'details', 'owner')
  * @return Resources\Project|boolean 
  */
 public function updateProject($id, $data)
 {
     if (empty($id)) {
         throw new Exception\InvalidArgumentException(self::ERR_ID_PROJECT);
     }
     if (!is_array($data) || !Resources\Project::validKeys($data)) {
         throw new Exception\InvalidArgumentException('The array of values is not valid for the project');
     }
     $result = $this->httpCall("/projects/{$id}", 'PUT', $data);
     if ($result === false) {
         return false;
     }
     $project = json_decode($result->getBody(), true);
     if (is_array($project)) {
         return new Resources\Project($this, $project);
     }
     return false;
 }