Пример #1
0
 public function testInvalidPut()
 {
     $volunteer = new Volunteer(BreadBasketTest::INVALID_KEY, $this->valid_org_id, $this->VALID_EMAIL, $this->VALID_EMAIL_ACTIVATION, $this->VALID_FIRST_NAME, $this->VALID_HASH, $this->VALID_ADMIN, $this->VALID_LAST_NAME, $this->VALID_PHONE, $this->VALID_SALT);
     $response = $this->guzzle->put('https://bootcamp-coders.cnm.edu/~kkeller13/bread-basket/public_html/php/api/volunteer/' . BreadBasketTest::INVALID_KEY, ['allow-redirects' => ['strict' => true], 'json' => $volunteer, 'headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //make sure the request returns the proper error code for a failed operation
     $body = $response->getBody();
     $retrievedVol = json_decode($body);
     $this->assertSame(404, $retrievedVol->status);
 }
 /**
  * test getting all listing Types
  */
 public function testValidGetAll2()
 {
     //test getting by parameter new listing type
     //create a new listing type, and insert into the database
     $listingType = new ListingType(null, $this->VALID_TYPE_2);
     $listingType->insert($this->getPDO());
     $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', ['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 response returned a non-empty array
     $this->assertGreaterThan(0, sizeof($retrievedListingType->data->listingTypeId));
 }
Пример #3
0
 /**
  * test posting an invalid organization to the API
  */
 public function testInvalidPost()
 {
     //test to make sure non-admin can't post
     //sign out as an admin, log-in as a volunteer
     $logout = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/controllers/sign-out-controller.php');
     $volLogin = new stdClass();
     $volLogin->email = "*****@*****.**";
     $volLogin->password = "******";
     $login = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/controllers/sign-in-controller.php', ['allow_redirects' => ['strict' => true], 'json' => $volLogin, 'headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //try to post to an organization
     $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);
     $response = $this->guzzle->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]]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $retrievedOrg = json_decode($body);
     //make sure the organization was not entered into the database
     $shouldNotExist = Organization::getOrganizationByOrgName($this->getPDO(), $this->VALID_NAME);
     $this->assertSame($shouldNotExist->getSize(), 0);
     //make sure 401 error is returned for trying to access an admin method as a volunteer
     $this->assertSame(401, $retrievedOrg->status);
 }