示例#1
0
 /**
  * test posting a valid organization to the API
  */
 public function testValidPost()
 {
     //get the count of the number of rows in the database
     $numRows = $this->getConnection()->getRowCount("organization");
     //create a new organization to send
     $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);
     //send organization info to api in a post method, also make sure the cookie is set
     $response = $this->guzzle->request('POST', 'https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/api/organization', ['allow_redirects' => ['strict' => true], 'json' => $organization, 'headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //make sure the status codes match
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $retrievedOrg = json_decode($body);
     $this->assertSame(200, $retrievedOrg->status);
     //ensure a new row was added to the database
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("organization"));
 }