$expected = [
'users' => [
[
- "name" => "mreyrolle", "mail" => "maxime.reyrolle@example.org", "firstname" => "Maxime", "lastname" => "Reyrolle"
+ "id" => 1, "name" => "mreyrolle", "mail" => "maxime.reyrolle@example.org", "firstname" => "Maxime", "lastname" => "Reyrolle"
],
[
- "name" => "aauzolat", "mail" => "arnaud.auzolat@example.org", "firstname" => "Arnaud", "lastname" => "Auzolat"
+ "id" => 2, "name" => "aauzolat", "mail" => "arnaud.auzolat@example.org", "firstname" => "Arnaud", "lastname" => "Auzolat"
]
],
'pagination' => [
}
public function testWhenAddingANewUser() {
+ $this->loadFixtures('Users');
+
$data = [
'name' => 'username',
'password' => 'password',
'name' => 'username',
'mail' => 'mail@example.org',
'firstname' => 'The firstname of the user',
- 'lastname' => 'The lastname of the user'
+ 'lastname' => 'The lastname of the user',
+ 'id' => 3
];
$expectedBody = $this->getExpectedValue($expected);
$this->loadFixtures('Users');
- $this->iSendAGetRequestTo('/users/aauzolat.json');
+ $this->iSendAGetRequestTo('/users/2.json');
$this->theResponseCodeShouldBe(200);
$expected = [
+ 'id' => 2,
'name' => 'aauzolat',
'mail' => 'arnaud.auzolat@example.org',
'firstname' => 'Arnaud',
public function testWhenFindingAnUnknownUser() {
$this->loadFixtures('Users');
- $this->iSendAGetRequestTo('/users/donotexist.json');
+ $this->iSendAGetRequestTo('/users/4.json');
$this->theResponseCodeShouldBe(404);
$expected = [
- 'message' => 'The user donotexist does not exist',
- 'url' => '/api/v1/users/donotexist.json',
+ 'message' => 'The user with the id 4 does not exist',
+ 'url' => '/api/v1/users/4.json',
'code' => 404
];
$expectedBody = $this->getExpectedValue($expected);
public function testWhenDeletingANotExistingUser() {
- $this->iSendADeleteRequestTo('/users/donotexist.json');
+ $this->iSendADeleteRequestTo('/users/4.json');
$this->theResponseCodeShouldBe(404);
$expected = [
- 'message' => 'The user donotexist does not exist',
- 'url' => '/api/v1/users/donotexist.json',
+ 'message' => 'The user with the id 4 does not exist',
+ 'url' => '/api/v1/users/4.json',
'code' => 404
];
$expectedBody = $this->getExpectedValue($expected);
public function testWhenDeletingAnExistingUser() {
$this->loadFixtures('Users');
- $this->iSendADeleteRequestTo('/users/aauzolat.json');
+ $this->iSendADeleteRequestTo('/users/2.json');
$this->theResponseCodeShouldBe(204);
}
];
$this->givenIHaveSomeDataToSend($data);
- $this->iSendAPutRequestTo('/users/aauzolat.json');
+ $this->iSendAPutRequestTo('/users/2.json');
$this->theResponseCodeShouldBe(200);
$expected = [
+ 'id' => 2,
'name' => 'aauzolat',
'mail' => 'new_mail@example.org',
'firstname' => 'new firstname',
];
$this->givenIHaveSomeDataToSend($data);
- $this->iSendAPutRequestTo('/users/donotexist.json');
+ $this->iSendAPutRequestTo('/users/4.json');
$this->theResponseCodeShouldBe(404);
$expected = [
- 'message' => 'The user donotexist does not exist',
- 'url' => '/api/v1/users/donotexist.json',
+ 'message' => 'The user with the id 4 does not exist',
+ 'url' => '/api/v1/users/4.json',
'code' => 404
];
-
+
$expectedBody = $this->getExpectedValue($expected);
$this->theResponseBodyShouldBe($expectedBody);
}
];
$this->givenIHaveSomeDataToSend($data);
- $this->iSendAPutRequestTo('/users/mreyrolle.json');
+ $this->iSendAPutRequestTo('/users/1.json');
$this->theResponseCodeShouldBe(400);
$expected = [
'code' => 400,
- 'url' => '/api/v1/users/mreyrolle.json',
+ 'url' => '/api/v1/users/1.json',
'message' => '3 validation errors occurred',
'errorCount' => 3,
'errors' => [