예제 #1
0
 /**
  * test updating a Company that already exists
  *
  * @expectedException PDOException
  **/
 public function testUpdateInvalidCompany()
 {
     // create a Company with a non null company id and watch it fail
     $company = new Company(null, $this->VALID_COMPANYNAME, $this->VALID_COMPANYADDRESS1, $this->VALID_COMPANYADDRESS2, $this->VALID_COMPANYATTN, $this->VALID_COMPANYSTATE, $this->VALID_COMPANYCITY, $this->VALID_COMPANYZIP, $this->VALID_COMPANYPHONE, $this->VALID_COMPANYEMAIL, $this->VALID_COMPANYURL);
     $company->update($this->getPDO());
 }
예제 #2
0
             throw new InvalidArgumentException("company city cannot be empty", 405);
         }
         if (empty($requestObject->companyEmail) === true) {
             throw new InvalidArgumentException("company email cannot be empty", 405);
         }
         if (empty($requestObject->companyUrl) === true) {
             $requestObject->companyUrl = null;
         }
         //perform the actual put or post
         if ($method === "PUT") {
             $company = Company::getCompanyByCompanyId($pdo, $companyId);
             if ($company === null) {
                 throw new RuntimeException("Company does not exist", 404);
             }
             $company = new Company($companyId, $requestObject->companyName, $requestObject->companyAddress1, $requestObject->companyAddress2, $requestObject->companyAttn, $requestObject->companyState, $requestObject->companyCity, $requestObject->companyZip, $requestObject->companyPhone, $requestObject->companyEmail, $requestObject->companyUrl);
             $company->update($pdo);
             $reply->message = "Company updated OK";
         } else {
             if ($method === "POST") {
                 $company = new Company(null, $requestObject->companyName, $requestObject->companyAddress1, $requestObject->companyAddress2, $requestObject->companyAttn, $requestObject->companyState, $requestObject->companyCity, $requestObject->companyZip, $requestObject->companyPhone, $requestObject->companyEmail, $requestObject->companyUrl);
                 $company->insert($pdo);
                 $reply->message = "Company created OK";
             }
         }
     }
 } else {
     if ($method === "DELETE") {
         verifyXsrf();
         $company = Company::getCompanyByCompanyId($pdo, $companyId);
         if ($company === null) {
             throw new RuntimeException("Company does not exist", 404);