Exemplo n.º 1
0
 public function testGetValidListingByOrgId()
 {
     //get the count of the number of rows in the database
     $numRows = $this->getConnection()->getRowCount("listing");
     //create a new listing and insert into mySQL
     $listing = new Listing(null, $this->organization->getOrgId(), $this->VALID_CLAIMEDBY, $this->VALID_LISTINGCLOSED, $this->VALID_COST, $this->VALID_MEMO, $this->VALID_PARENT_ID, $this->valid_datetime, $this->listingType->getListingTypeId());
     $listing->insert($this->getPDO());
     //grab data from SQL and ensure it matches
     $pdoListing = Listing::getListingByOrgId($this->getPDO(), $listing->getOrgId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("listing"));
     $this->assertSame($pdoListing[0]->getOrgId(), $this->organization->getOrgId());
     $this->assertSame($pdoListing[0]->getListingClaimedBy(), $this->VALID_CLAIMEDBY);
     $this->assertSame($pdoListing[0]->getListingClosed(), $this->VALID_LISTINGCLOSED);
     $this->assertSame($pdoListing[0]->getListingCost(), $this->VALID_COST);
     $this->assertSame($pdoListing[0]->getListingMemo(), $this->VALID_MEMO);
     $this->assertSame($pdoListing[0]->getListingParentId(), $this->VALID_PARENT_ID);
     $this->assertEquals($pdoListing[0]->getListingPostTime(), $this->valid_datetime);
     $this->assertSame($pdoListing[0]->getListingTypeId(), $this->listingType->getlistingTypeId());
 }
Exemplo n.º 2
0
 /**
  * test deleting a valid listing in the database
  * */
 public function testValidDelete()
 {
     //create a new listing, and insert it
     $listing = new Listing(null, $this->organization->getOrgId(), $this->VALID_CLAIMEDBY, $this->VALID_LISTINGCLOSED, $this->VALID_COST, $this->VALID_MEMO, $this->VALID_PARENT_ID, $this->valid_datetime, $this->listingType->getListingTypeId());
     $listing->insert($this->getPDO());
     //perform the actual delete
     $response = $this->guzzle->delete('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/api/listing/' . $listing->getListingId(), ['headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //grab the data from guzzle and enforce that the status codes are correct
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $retrievedListing = json_decode($body);
     $this->assertSame(200, $retrievedListing->status);
     //try retrieving entry from database and ensure it was deleted
     $deletedListing = Listing::getListingByListingId($this->getPDO(), $listing->getOrgId());
     $this->assertNull($deletedListing);
 }