public function editAnAuthorWithInvalidAttributes(FunctionalTester $I)
 {
     $author = $I->haveAuthor();
     $attributes = ['id' => $author->id, 'name' => 'Updated Author2', 'email' => 'debug'];
     $I->sendPUT('/authors/' . $author->id, $attributes);
     $I->sendGET('/authors');
     $I->dontSeeResponseContainsJson($attributes);
 }
示例#2
0
 public function updateItem(FunctionalTester $I, $scenario)
 {
     $I->wantTo('modify an existing item');
     $I->sendPUT('/vehicles/123', ['name' => 'Pansy updated']);
     $scenario->incomplete('work in progress');
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['id' => 123, 'name' => 'Pansy updated']);
 }
示例#3
0
 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);
 }
示例#4
0
 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);
 }
示例#5
0
 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);
 }
示例#6
0
 public function tryToLinkUnlinkEvents(FunctionalTester $I)
 {
     $I->haveInCollection('Event', ['name' => 'event1']);
     $event1Id = (string) ($dbUser = $I->grabFromCollection('Event', ['name' => 'event1'])['_id']);
     $I->haveInCollection('Event', ['name' => 'event2']);
     $event2Id = (string) ($dbUser = $I->grabFromCollection('Event', ['name' => 'event2'])['_id']);
     $I->sendPUT('api/events/' . $event1Id . '/users/' . $this->userId . '.json');
     $I->seeResponseCodeIs(401);
     $I->sendDELETE('api/events/' . $event1Id . '/users/' . $this->userId . '.json');
     $I->seeResponseCodeIs(401);
     $I->login($this->user['email']);
     $I->sendPUT('api/events/' . $event1Id . '/users/' . $this->userId . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/users/current.json');
     $I->seeResponseContainsJson(['events' => [['id' => $event1Id]]]);
     $I->dontseeResponseContainsJson(['events' => [['id' => $event2Id]]]);
     $I->sendPUT('api/events/' . $event2Id . '/users/' . $this->userId . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/users/current.json');
     $I->seeResponseContainsJson(['events' => [['id' => $event1Id]]]);
     $I->seeResponseContainsJson(['events' => [['id' => $event2Id]]]);
     $I->sendDELETE('api/events/' . $event1Id . '/users/' . $this->userId . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/users/current.json');
     $I->seeResponseCodeIs(200);
     $I->dontseeResponseContainsJson(['events' => [['id' => $event1Id]]]);
     $I->seeResponseContainsJson(['events' => [['id' => $event2Id]]]);
     $I->sendGET('api/events/' . $event1Id . '.json');
     $I->seeResponseCodeIs(200);
     $I->dontseeResponseContainsJson(['users' => [['id' => $this->userId]]]);
     $I->sendGET('api/events/' . $event2Id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson(['users' => [['id' => $this->userId]]]);
     $I->sendPUT('api/events/' . $event2Id . '/users/' . $this->adminId . '.json');
     $I->seeResponseCodeIs(204);
     $I->sendGET('api/events/' . $event2Id . '.json');
     $I->seeResponseCodeIs(200);
     $I->seeResponseContainsJson(['users' => [['id' => $this->userId], ['id' => $this->adminId]]]);
 }