コード例 #1
0
 /**
  * test inserting an organization and regrabbing it from mySQL
  */
 public function testGetValidListingTypeById()
 {
     //count the rows in the database
     $numRows = $this->getConnection()->getRowCount("listingType");
     $listingtype = new ListingType(null, $this->VALID_TYPE);
     $listingtype->insert($this->getPDO());
     //grab data from SQL and ensure it matches
     $pdoListingType = ListingType::getListingTypeById($this->getPDO(), $listingtype->getListingTypeId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("listingType"));
     $this->assertSame($pdoListingType->getListingTypeInfo(), $this->VALID_TYPE);
 }
コード例 #2
0
 public function testValidGet()
 {
     //test getting by parameter new listing type
     //create a new listing type, and insert into the database
     $listingType = new ListingType(null, $this->VALID_TYPE);
     $listingType->insert($this->getPDO());
     //send the get request to the API
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~tfenstermaker/bread-basket/public_html/php/api/listingtype/' . $listingType->getListingTypeId(), ['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();
     $retrievedListingType = json_decode($body);
     $this->assertSame(200, $retrievedListingType->status);
     //ensure the returned values meet expectations (just checking enough to make sure the right thing was obtained)
     $this->assertSame($retrievedListingType->data->listingTypeId, $listingType->getListingTypeId());
     $this->assertSame($retrievedListingType->data->listingTypeInfo, $this->VALID_TYPE);
 }