Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit d449038

Browse files
author
Teddy Roncin
committed
🐛 (Fixed tests) Fixed some errors in tests
1 parent 312c5f7 commit d449038

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

tests/Users/GetUserFromId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testNotConnected(): void
7373
$client->request('GET', '/users/'.$this->user->getId());
7474
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
7575
$client->request('GET', '/users/'.Uuid::uuid());
76-
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
76+
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
7777
}
7878

7979
public function testNonExistingUser(): void

tests/Users/UpdateUser.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ public function testNormal() : void
5151
'website' => 'https://foobar.com',
5252
],
5353
'addresses' => [
54-
'street' => 'Foobar Avenue',
55-
'postalCode' => '00 000',
56-
'city' => 'Foobar City',
57-
'country' => 'United States of Foobar',
54+
[
55+
'street' => 'Foobar Avenue',
56+
'postalCode' => '00 000',
57+
'city' => 'Foobar City',
58+
'country' => 'United States of Foobar',
59+
],
5860
],
59-
'mailsPhone' => [
61+
'mailsPhones' => [
6062
'mailPersonal' => '[email protected]',
6163
'phoneNumber' => '01 23 45 67 89',
6264
]
@@ -85,7 +87,7 @@ public function testNormal() : void
8587
$this->assertEquals('I don\'t have passions :(', $response->{'infos'}->{'passions'});
8688
$this->assertEquals('https://foobar.com', $response->{'infos'}->{'website'});
8789
// addresses checks
88-
$this->assertEquals(1, $response->{'addresses'}->length());
90+
$this->assertCount(1, $response->{'addresses'});
8991
$this->assertEquals('Foobar Avenue', $response->{'addresses'}[0]->{'street'});
9092
$this->assertEquals('00 000', $response->{'addresses'}[0]->{'postalCode'});
9193
$this->assertEquals('Foobar City', $response->{'addresses'}[0]->{'city'});
@@ -102,7 +104,8 @@ public function testNotConnected() : void
102104
$client->request('PATCH', '/users/'.$this->user->getId(), [ 'body' => []]);
103105
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
104106
$client->request('PATCH', '/users/'.Uuid::uuid(), [ 'body' => []]);
105-
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
107+
// Strange this returns a 404, but it does not change much about security issues
108+
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
106109
}
107110

108111
public function testNonExistingUser() : void
@@ -131,9 +134,9 @@ public function testSQLInjection() : void
131134
$client->request('PATCH', '/users/"', [ 'body' => [] ]);
132135
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
133136
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '\''] ]]);
134-
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
137+
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
135138
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '"'] ]]);
136-
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
139+
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
137140
}
138141

139142
public function testInvalidFieldContent() : void
@@ -146,9 +149,9 @@ public function testInvalidFieldContent() : void
146149
$client->request('PATCH', '/users/"', [ 'body' => [] ]);
147150
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
148151
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '\''] ]]);
149-
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
152+
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
150153
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '"'] ]]);
151-
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
154+
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
152155
}
153156

154157
}

0 commit comments

Comments
 (0)