Esempio n. 1
0
 public function actionTestUpdateOrganization()
 {
     $organizationId = "55794e302336f240060041a8";
     $userId = "55c0c1a72336f213040041ee";
     $organization = array("name" => "Ekopratik");
     var_dump(Organization::update($organizationId, $organization, $userId));
 }
Esempio n. 2
0
         throw new InvalidArgumentException("organization state cannot be empty", 405);
     }
     if (empty($requestObject->orgType) === true) {
         throw new InvalidArgumentException("organization type cannot be empty", 405);
     }
     if (empty($requestObject->orgZip) === true) {
         throw new InvalidArgumentException("organization zip code cannot be empty", 405);
     }
     //perform the actual put or post
     if ($method === "PUT") {
         $organization = Organization::getOrganizationByOrgId($pdo, $id);
         if ($organization === null) {
             throw new RuntimeException("Organization does not exist", 404);
         }
         $organization = new Organization($id, $requestObject->orgAddress1, $requestObject->orgAddress2, $requestObject->orgCity, $requestObject->orgDescription, $requestObject->orgHours, $requestObject->orgName, $requestObject->orgPhone, $requestObject->orgState, $requestObject->orgType, $requestObject->orgZip);
         $organization->update($pdo);
         $reply->message = "Organization updated OK";
     } else {
         if ($method === "POST") {
             $organization = new Organization(null, $requestObject->orgAddress1, $requestObject->orgAddress2, $requestObject->orgCity, $requestObject->orgDescription, $requestObject->orgHours, $requestObject->orgName, $requestObject->orgPhone, $requestObject->orgState, $requestObject->orgType, $requestObject->orgZip);
             $organization->insert($pdo);
             $reply->message = "Organization created OK";
         }
     }
 } else {
     if ($method === "DELETE") {
         //verifyXsrf();
         $organization = Organization::getOrganizationByOrgId($pdo, $id);
         if ($organization === null) {
             throw new RuntimeException("Organization does not exist", 404);
         }
 /**
  * test updating an organization that does not exist
  *
  * @expectedException PDOException
  */
 public function testUpdateInvalidOrganization()
 {
     //create an organization and try to update without inserting first
     $organization = new Organization(null, $this->VALID_ADDRESS1, $this->VALID_ADDRESS2, $this->VALID_CITY, $this->VALID_DESCRIPTION, $this->VALID_HOURS, $this->VALID_NAME, $this->VALID_PHONE, $this->VALID_STATE, $this->VALID_TYPE, $this->VALID_ZIP);
     $organization->update($this->getPDO());
 }