/**
  * test inserting an organization, editing it, then updating it
  */
 public function testUpdateValidOrganization()
 {
     //get the count of the number of rows in the database
     $numRows = $this->getConnection()->getRowCount("organization");
     //create a new organization and insert into mySQL
     $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->insert($this->getPDO());
     //edit the organization and update it in mySQL
     $organization->setOrgName($this->VALID_NAME_ALT);
     $organization->update($this->getPDO());
     //grab data from SQL and ensure it matches
     $pdoOrganization = Organization::getOrganizationByOrgId($this->getPDO(), $organization->getOrgId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("organization"));
     $this->assertSame($pdoOrganization->getOrgAddress1(), $this->VALID_ADDRESS1);
     $this->assertSame($pdoOrganization->getOrgAddress2(), $this->VALID_ADDRESS2);
     $this->assertSame($pdoOrganization->getOrgCity(), $this->VALID_CITY);
     $this->assertSame($pdoOrganization->getOrgDescription(), $this->VALID_DESCRIPTION);
     $this->assertSame($pdoOrganization->getOrgHours(), $this->VALID_HOURS);
     $this->assertSame($pdoOrganization->getOrgName(), $this->VALID_NAME_ALT);
     $this->assertSame($pdoOrganization->getOrgPhone(), $this->VALID_PHONE);
     $this->assertSame($pdoOrganization->getOrgState(), $this->VALID_STATE);
     $this->assertSame($pdoOrganization->getOrgType(), $this->VALID_TYPE);
     $this->assertSame($pdoOrganization->getOrgZip(), $this->VALID_ZIP);
 }
Esempio n. 2
0
 /**
  * test putting a valid organization into the API
  */
 public function testValidPut()
 {
     //create a new organization, and insert into the database
     $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->insert($this->getPDO());
     //update the organization
     $organization->setOrgName($this->VALID_NAME_ALT);
     //send the info to update to the API
     $response = $this->guzzle->put('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/api/organization/' . $organization->getOrgId(), ['allow-redirects' => ['strict' => true], 'json' => $organization, 'headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //ensure the response was sent, and the api returned a positive status
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $retrievedOrg = json_decode($body);
     $this->assertSame(200, $retrievedOrg->status);
     //pull the value from the DB, and make sure it was properly updated
     $neworg = Organization::getOrganizationByOrgId($this->getPDO(), $organization->getOrgId());
     $this->assertSame($neworg->getOrgName(), $this->VALID_NAME_ALT);
 }