Example #1
0
 /**
  * test posting a valid message to the API
  */
 public function testPostValidMessage()
 {
     //get the count of the numbers of rows in the database
     $numRows = $this->getConnection()->getRowCount("message");
     //create a new message to send
     $newMessage = new Message(null, $this->VALID_MESSAGE_ID, $this->VALID_LISTING_Id, $this->VALID_ORG_ID, $this->VALID_MESSAGE_ID, $this->VALID_MESSAGE_TEXT);
     //run a get request to establish session tokens
     $this->guzzle->get('http://bootcamp-coders.cnm.edu/~bread-basket/public_html/php/api/message/');
     //Grab the Data from guzzle and enforce the status match our expectations
     $response = $this->guzzle->post('http://bootcamp-coders.cnm.edu/~bread-basket/public_html/php/api/', ['headers' => ['X-XRF-TOKEN' => $this->getXsrfToken()], 'json' => $newMessage]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $alertLevel = jason_decode($body);
     $this->assertSame(200, $alertLevel->status);
     //ensure a new row was added to the database
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("message"));
 }
Example #2
0
     // Scene commands
 // Scene commands
 case "add_scene":
     $apperr .= "Calling add_scene:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = add_scene($icsmsg);
     $apperr .= "\nScene added ";
     $ret = $tcnt;
     break;
 case "upd_scene":
     $apperr .= "Calling upd_scene:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = store_scene($icsmsg);
     $apperr .= "\nScene updated ";
     $ret = $tcnt;
     break;
 case "store_scene":
     $apperr .= "Calling store_scene:: jsonmsg: " . jason_decode($icsmsg) . "\n";
     $tcnt = store_scene($icsmsg);
     $apperr .= "\nScene stored ";
     $ret = $tcnt;
     break;
 case "delete_scene":
     $apperr .= "Calling delete_scene:: json: " . json_decode($icsmsg) . "\n";
     $tcnt = delete_scene($icsmsg);
     $apperr .= "\nScene deleted ";
     $ret = $tcnt;
     break;
     // Timer database functions
 // Timer database functions
 case "add_timer":
     $apperr .= "Calling add_timer:: icsmsg: " . $icsmsg . ", json: " . json_decode($icsmsg) . "\n";
     $tcnt = add_timer($icsmsg);