コード例 #1
0
 public function createAnInvalidAuthor(FunctionalTester $I)
 {
     $attributes = ['name' => 'Author2', 'email' => 'debug'];
     $I->sendPOST('/authors', $attributes);
     $I->sendGET('/authors');
     $I->dontSeeResponseContainsJson($attributes);
 }
コード例 #2
0
ファイル: ContentsCest.php プロジェクト: x-team/x-map
 public function tryToCreateModifyAndDeleteContent(FunctionalTester $I)
 {
     $I->am('Anonymous user');
     $I->sendPOST('api/contents.json', $this->content3);
     $I->seeResponseCodeIs(401);
     $I->sendPUT('api/contents/' . $this->content2['key'] . '.json');
     $I->seeResponseCodeIs(401);
     $I->sendDELETE('api/contents/' . $this->content2['key'] . '.json');
     $I->seeResponseCodeIs(401);
     $I->am('ROLE_USER');
     $I->login($this->user['email']);
     $I->sendPOST('api/contents.json', $this->content3);
     $I->seeResponseCodeIs(403);
     $I->sendPUT('api/contents/' . $this->content2['key'] . '.json');
     $I->seeResponseCodeIs(403);
     $I->sendDELETE('api/contents/' . $this->content2['key'] . '.json');
     $I->seeResponseCodeIs(403);
     $I->am('ROLE_ADMIN');
     $I->login($this->admin['email']);
     $I->sendPOST('api/contents.json', $this->content3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->content3);
     $id = $I->grabDataFromResponseByJsonPath('$.id')[0];
     $I->sendGET('api/contents/' . $this->content3['key'] . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->content3);
     $I->sendGET('api/contents/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->content3);
     $this->content3['title'] = 'new title';
     $I->sendPUT('api/contents/' . $id . '.json', $this->content3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->content3);
     $I->sendGET('api/contents/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->content3);
     $I->sendDELETE('api/contents/' . $id . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/contents/' . $id . '.json');
     $I->seeResponseCodeIs(404);
     $I->logout();
     $I->sendGET('api/contents/' . $id . '.json');
     $I->seeResponseCodeIs(401);
 }
コード例 #3
0
ファイル: EventsCest.php プロジェクト: x-team/x-map
 public function tryToCreateModifyAndDeleteEvent(FunctionalTester $I)
 {
     $I->am('Anonymous user');
     $I->sendPOST('api/events.json', $this->event3);
     $I->seeResponseCodeIs(401);
     $I->sendPUT('api/events/' . $this->event2Id . '.json');
     $I->seeResponseCodeIs(401);
     $I->sendDELETE('api/events/' . $this->event2Id . '.json');
     $I->seeResponseCodeIs(401);
     $I->am('ROLE_USER');
     $I->login($this->user['email']);
     $I->sendPOST('api/events.json', $this->event3);
     $I->seeResponseCodeIs(400);
     $this->event3['type'] = 'conference';
     $I->sendPOST('api/events.json', $this->event3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->event3);
     $id = $I->grabDataFromResponseByJsonPath('$.id')[0];
     $I->sendGET('api/events/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->event3);
     $this->event3['name'] = 'new name';
     $I->sendPUT('api/events/' . $id . '.json', $this->event3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->event3);
     $I->sendGET('api/events/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->event3);
     $I->sendDELETE('api/events/' . $id . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/events/' . $id . '.json');
     $I->seeResponseCodeIs(404);
     $I->sendPOST('api/events.json', $this->event4);
     $I->seeResponseCodeIs(200);
     $this->event4['dateEnd'] = $this->event4['dateStart'];
     $I->seeResponseContainsJson($this->event4);
     $id = $I->grabDataFromResponseByJsonPath('$.id')[0];
     $this->event4['data'] = ['some' => ['custom', 'data'], 'to' => ['check' => 'if arbitrary data can be stored']];
     $I->sendPUT('api/events/' . $id . '.json', $this->event4);
     $I->sendGET('api/events/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->event4);
 }
コード例 #4
0
ファイル: TeamsCest.php プロジェクト: x-team/x-map
 public function tryToCreateModifyAndDeleteTeam(FunctionalTester $I)
 {
     $I->am('Anonymous user');
     $I->sendPOST('api/teams.json', $this->team3);
     $I->seeResponseCodeIs(401);
     $I->sendPUT('api/teams/' . $this->team2Id . '.json');
     $I->seeResponseCodeIs(401);
     $I->sendDELETE('api/teams/' . $this->team2Id . '.json');
     $I->seeResponseCodeIs(401);
     $I->am('ROLE_USER');
     $I->login($this->user['email']);
     $I->sendPOST('api/teams.json', $this->team3);
     $I->seeResponseCodeIs(403);
     $I->sendPUT('api/teams/' . $this->team2Id . '.json');
     $I->seeResponseCodeIs(403);
     $I->sendDELETE('api/teams/' . $this->team2Id . '.json');
     $I->seeResponseCodeIs(403);
     $I->am('ROLE_ADMIN');
     $I->login($this->admin['email']);
     $I->sendPOST('api/teams.json', $this->team3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->team3);
     $id = $I->grabDataFromResponseByJsonPath('$.id')[0];
     $I->sendGET('api/teams/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->team3);
     $I->sendGET('api/teams/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->team3);
     $this->team3['name'] = 'new name';
     $I->sendPUT('api/teams/' . $id . '.json', $this->team3);
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->team3);
     $I->sendGET('api/teams/' . $id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson($this->team3);
     $I->sendDELETE('api/teams/' . $id . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/teams/' . $id . '.json');
     $I->seeResponseCodeIs(404);
 }
コード例 #5
0
ファイル: VehiclesCest.php プロジェクト: tekkie/autolog-api
 public function createItem(FunctionalTester $I, $scenario)
 {
     $I->wantTo('create a new vehicle');
     $I->sendPOST('/vehicles', ['name' => 'Pansy']);
     // we mark scenario as not implemented
     $scenario->incomplete('work in progress');
     // here's what we think should happen
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseJsonMatchesXpath('//id');
     $I->seeResponseJsonMatchesXpath('//name');
     $I->seeResponseMatchesJsonType(['id' => 'integer', 'name' => 'string']);
     $I->seeResponseContainsJson(['id' => 123, 'name' => 'Pansy']);
 }
コード例 #6
0
 public function memberCantAddCash(FunctionalTester $I)
 {
     $I->am('a member');
     $I->wantTo('make sure I cant add cash payments to my account');
     //Load and login a known member
     $user = User::find(1);
     Auth::login($user);
     //I cant see option
     $I->amOnPage('/account/' . $user->id . '');
     $I->cantSee('Record a cash balance payment');
     //Make sure they cant post payment directly
     //Confirm that posting directly generates a validation exception
     $I->sendPOST('/account/' . $user->id . '/payment/cash/create', ['reason' => 'balance', 'amount' => 4.69, 'return_path' => '/']);
     $I->seeResponseCodeIs(403);
     //One final check
     $I->cantSeeInDatabase('payments', ['amount' => 4.69]);
 }
コード例 #7
0
 public function memberCantSneakyVoteOnNotStartedProposal(FunctionalTester $I)
 {
     $I->am('a member');
     $I->wantTo('make sure I cant sneakily vote on a proposal that hasnt started yet');
     //Create a proposal starting in the future
     $startDate = Carbon::now()->addDay()->format('Y-m-d');
     $endDate = Carbon::now()->addDays(3)->format('Y-m-d');
     $I->haveInDatabase('proposals', ['id' => 4, 'title' => 'Proposal 4', 'description' => 'Demo Description', 'user_id' => '1', 'start_date' => $startDate, 'end_date' => $endDate]);
     //Load and login a known member
     $user = User::find(1);
     Auth::login($user);
     //I can see the menu item
     $I->amOnPage('/proposals');
     $I->canSee('Proposal 4');
     $I->seeExceptionThrown('BB\\Exceptions\\ValidationException', function ($I) {
         //Confirm that posting directly generates a validation exception
         $I->sendPOST('/proposals/4', ['vote' => '+1']);
     });
 }
コード例 #8
0
 public function InvalidParam_6(Tester $I)
 {
     $time = time();
     $I->wantTo('Test invalid source');
     $I->haveHttpHeader("apikey", $this->apikey);
     $I->haveHttpHeader("timestamp", $time);
     $I->haveHttpHeader("fingerprint", Helper::createFingerPrint($this->apikey, $this->secret, $time, 'POST', $this->resourceURL, $this->nric, $this->amount, $this->date, $this->source));
     $I->haveHttpHeader("Content-Type", 'application/x-www-form-urlencoded');
     $I->sendPOST("updates", Helper::assemblePostData($this->nric, $this->amount, $this->date, "airfares"));
     $I->seeResponseCodeIs(401);
 }