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

Commit 7b353c7

Browse files
author
Teddy Roncin
committed
🚨 (tests) Linted tests folder
1 parent b2b9718 commit 7b353c7

File tree

4 files changed

+64
-64
lines changed

4 files changed

+64
-64
lines changed

tests/Groups/GetGroupFromSlug.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
use App\Tests\EtuUTTApiTestCase;
88
use Symfony\Component\HttpFoundation\Response;
99

10-
class GetGroupFromSlug extends EtuUTTApiTestCase
10+
/**
11+
* @internal
12+
*
13+
* @coversNothing
14+
*/
15+
final class GetGroupFromSlug extends EtuUTTApiTestCase
1116
{
12-
1317
public function testNormal(): void
1418
{
1519
static::loadFixtures(new GroupSeeder());
@@ -47,5 +51,4 @@ public function testSqlInjection(): void
4751
$client->request('GET', '/groups/"');
4852
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
4953
}
50-
5154
}

tests/Groups/GetGroups.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* @internal
12+
*
1213
* @coversNothing
1314
*/
1415
final class GetGroups extends EtuUTTApiTestCase

tests/Groups/UpdateGroup.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Tests\Groups;
44

55
use App\Entity\Group;
6-
use App\Repository\GroupRepository;
76
use App\Tests\EtuUTTApiTestCase;
87
use Faker\Provider\Uuid as FakerUuid;
98
use Symfony\Component\HttpFoundation\Response;

tests/Users/UpdateUser.php

Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,28 @@
22

33
namespace App\Tests\Users;
44

5-
use App\DataFixtures\UserSeeder;
6-
use App\Entity\User;
7-
use App\Entity\UserAddress;
8-
use App\Repository\UserRepository;
95
use App\Tests\EtuUTTApiTestCase;
10-
use DateTimeInterface;
11-
use Faker\Provider\Address;
126
use Faker\Provider\Uuid;
137
use Symfony\Component\HttpFoundation\Response;
148

15-
class UpdateUser extends EtuUTTApiTestCase
9+
/**
10+
* @internal
11+
*
12+
* @coversNothing
13+
*/
14+
final class UpdateUser extends EtuUTTApiTestCase
1615
{
17-
18-
public function testNormal() : void
16+
public function testNormal(): void
1917
{
2018
$client = static::createClient();
21-
$client->setDefaultOptions([ 'headers' => [ 'CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json' ]]);
19+
$client->setDefaultOptions(['headers' => ['CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json']]);
2220
$testUser = $this->createUser('Foo', 'Bar', 'foobar');
2321
$testUserId = $testUser->getId();
2422
$testUserStudentId = $testUser->getStudentId();
2523
$testUserNationality = $testUser->getInfos()->getNationality();
26-
$testUserBirthday = $testUser->getInfos()->getBirthday()->format(DateTimeInterface::RFC3339);
24+
$testUserBirthday = $testUser->getInfos()->getBirthday()->format(\DateTimeInterface::RFC3339);
2725
$testUserAvatar = $testUser->getInfos()->getAvatar();
28-
$crawler = $client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => json_encode([
26+
$crawler = $client->request('PATCH', '/users/'.$testUser->getId(), ['body' => json_encode([
2927
'socialNetwork' => [
3028
'facebook' => 'https://facebook.com/foobar',
3129
'twitter' => 'https://twitter.com/foobar',
@@ -61,97 +59,96 @@ public function testNormal() : void
6159
'mailsPhones' => [
6260
'mailPersonal' => '[email protected]',
6361
'phoneNumber' => '01 23 45 67 89',
64-
]
62+
],
6563
])]);
6664
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
6765
$response = json_decode($crawler->getContent());
6866
// User checks
69-
$this->assertEquals($testUserId->jsonSerialize(), $response->{'id'});
70-
$this->assertEquals('foobar', $response->{'login'});
71-
$this->assertEquals($testUserStudentId, $response->{'studentId'});
72-
$this->assertEquals('Foo', $response->{'firstName'});
73-
$this->assertEquals('Bar', $response->{'lastName'});
67+
static::assertSame($testUserId->jsonSerialize(), $response->{'id'});
68+
static::assertSame('foobar', $response->{'login'});
69+
static::assertSame($testUserStudentId, $response->{'studentId'});
70+
static::assertSame('Foo', $response->{'firstName'});
71+
static::assertSame('Bar', $response->{'lastName'});
7472
// socialNetwork checks
75-
$this->assertEquals('https://facebook.com/foobar', $response->{'socialNetwork'}->{'facebook'});
76-
$this->assertEquals('https://twitter.com/foobar', $response->{'socialNetwork'}->{'twitter'});
77-
$this->assertEquals('https://instagram.com/foobar', $response->{'socialNetwork'}->{'instagram'});
78-
$this->assertEquals('https://linkedin.com/foobar', $response->{'socialNetwork'}->{'linkedin'});
79-
$this->assertEquals('FooBar', $response->{'socialNetwork'}->{'pseudoDiscord'});
80-
$this->assertEquals(true, $response->{'socialNetwork'}->{'wantDiscordUTT'});
73+
static::assertSame('https://facebook.com/foobar', $response->{'socialNetwork'}->{'facebook'});
74+
static::assertSame('https://twitter.com/foobar', $response->{'socialNetwork'}->{'twitter'});
75+
static::assertSame('https://instagram.com/foobar', $response->{'socialNetwork'}->{'instagram'});
76+
static::assertSame('https://linkedin.com/foobar', $response->{'socialNetwork'}->{'linkedin'});
77+
static::assertSame('FooBar', $response->{'socialNetwork'}->{'pseudoDiscord'});
78+
static::assertTrue($response->{'socialNetwork'}->{'wantDiscordUTT'});
8179
// infos checks
82-
$this->assertEquals('Féminin', $response->{'infos'}->{'sex'});
83-
$this->assertEquals($testUserNationality, $response->{'infos'}->{'nationality'});
84-
$this->assertEquals($testUserBirthday, $response->{'infos'}->{'birthday'});
85-
$this->assertEquals($testUserAvatar, $response->{'infos'}->{'avatar'});
86-
$this->assertEquals('foobar', $response->{'infos'}->{'nickname'});
87-
$this->assertEquals('I don\'t have passions :(', $response->{'infos'}->{'passions'});
88-
$this->assertEquals('https://foobar.com', $response->{'infos'}->{'website'});
80+
static::assertSame('Féminin', $response->{'infos'}->{'sex'});
81+
static::assertSame($testUserNationality, $response->{'infos'}->{'nationality'});
82+
static::assertSame($testUserBirthday, $response->{'infos'}->{'birthday'});
83+
static::assertSame($testUserAvatar, $response->{'infos'}->{'avatar'});
84+
static::assertSame('foobar', $response->{'infos'}->{'nickname'});
85+
static::assertSame('I don\'t have passions :(', $response->{'infos'}->{'passions'});
86+
static::assertSame('https://foobar.com', $response->{'infos'}->{'website'});
8987
// addresses checks
90-
$this->assertCount(1, $response->{'addresses'});
91-
$this->assertEquals('Foobar Avenue', $response->{'addresses'}[0]->{'street'});
92-
$this->assertEquals('00 000', $response->{'addresses'}[0]->{'postalCode'});
93-
$this->assertEquals('Foobar City', $response->{'addresses'}[0]->{'city'});
94-
$this->assertEquals('United States of Foobar', $response->{'addresses'}[0]->{'country'});
88+
static::assertCount(1, $response->{'addresses'});
89+
static::assertSame('Foobar Avenue', $response->{'addresses'}[0]->{'street'});
90+
static::assertSame('00 000', $response->{'addresses'}[0]->{'postalCode'});
91+
static::assertSame('Foobar City', $response->{'addresses'}[0]->{'city'});
92+
static::assertSame('United States of Foobar', $response->{'addresses'}[0]->{'country'});
9593
// mailsPhones checks
96-
$this->assertEquals('[email protected]', $response->{'mailsPhones'}->{'mailPersonal'});
97-
$this->assertEquals('01 23 45 67 89', $response->{'mailsPhones'}->{'phoneNumber'});
94+
static::assertSame('[email protected]', $response->{'mailsPhones'}->{'mailPersonal'});
95+
static::assertSame('01 23 45 67 89', $response->{'mailsPhones'}->{'phoneNumber'});
9896
}
9997

100-
public function testNotConnected() : void
98+
public function testNotConnected(): void
10199
{
102100
$client = static::createClient();
103-
$client->setDefaultOptions([ 'headers' => ['Content-Type' => 'application/merge-patch+json' ]]);
104-
$client->request('PATCH', '/users/'.$this->user->getId(), [ 'body' => []]);
101+
$client->setDefaultOptions(['headers' => ['Content-Type' => 'application/merge-patch+json']]);
102+
$client->request('PATCH', '/users/'.$this->user->getId(), ['body' => []]);
105103
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
106-
$client->request('PATCH', '/users/'.Uuid::uuid(), [ 'body' => []]);
104+
$client->request('PATCH', '/users/'.Uuid::uuid(), ['body' => []]);
107105
// Strange this returns a 404, but it does not change much about security issues
108106
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
109107
}
110108

111-
public function testNonExistingUser() : void
109+
public function testNonExistingUser(): void
112110
{
113111
$client = static::createClient();
114-
$client->setDefaultOptions([ 'headers' => [ 'CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json' ]]);
115-
$client->request('PATCH', '/users/'.Uuid::uuid(), [ 'body' => []]);
112+
$client->setDefaultOptions(['headers' => ['CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json']]);
113+
$client->request('PATCH', '/users/'.Uuid::uuid(), ['body' => []]);
116114
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
117115
}
118116

119-
public function testNoParameter() : void
117+
public function testNoParameter(): void
120118
{
121119
$client = static::createClient();
122-
$client->setDefaultOptions([ 'headers' => [ 'CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json' ]]);
120+
$client->setDefaultOptions(['headers' => ['CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json']]);
123121
$client->request('PATCH', '/users/'.$this->user->getId());
124122
$this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST);
125123
}
126124

127-
public function testSQLInjection() : void
125+
public function testSQLInjection(): void
128126
{
129127
$client = static::createClient();
130-
$client->setDefaultOptions([ 'headers' => [ 'CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json' ]]);
128+
$client->setDefaultOptions(['headers' => ['CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json']]);
131129
$testUser = $this->createUser('foo', 'bar', 'foobar');
132-
$client->request('PATCH', '/users/\'', [ 'body' => [] ]);
130+
$client->request('PATCH', '/users/\'', ['body' => []]);
133131
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
134-
$client->request('PATCH', '/users/"', [ 'body' => [] ]);
132+
$client->request('PATCH', '/users/"', ['body' => []]);
135133
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
136-
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '\''] ]]);
134+
$client->request('PATCH', '/users/'.$testUser->getId(), ['body' => ['socialNetwork' => ['facebook' => '\'']]]);
137135
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
138-
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '"'] ]]);
136+
$client->request('PATCH', '/users/'.$testUser->getId(), ['body' => ['socialNetwork' => ['facebook' => '"']]]);
139137
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
140138
}
141139

142-
public function testInvalidFieldContent() : void
140+
public function testInvalidFieldContent(): void
143141
{
144142
$client = static::createClient();
145-
$client->setDefaultOptions([ 'headers' => [ 'CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json' ]]);
143+
$client->setDefaultOptions(['headers' => ['CAS-LOGIN' => 'test', 'Content-Type' => 'application/merge-patch+json']]);
146144
$testUser = $this->createUser('foo', 'bar', 'foobar');
147-
$client->request('PATCH', '/users/\'', [ 'body' => [] ]);
145+
$client->request('PATCH', '/users/\'', ['body' => []]);
148146
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
149-
$client->request('PATCH', '/users/"', [ 'body' => [] ]);
147+
$client->request('PATCH', '/users/"', ['body' => []]);
150148
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
151-
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '\''] ]]);
149+
$client->request('PATCH', '/users/'.$testUser->getId(), ['body' => ['socialNetwork' => ['facebook' => '\'']]]);
152150
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
153-
$client->request('PATCH', '/users/'.$testUser->getId(), [ 'body' => [ 'socialNetwork' => ['facebook' => '"'] ]]);
151+
$client->request('PATCH', '/users/'.$testUser->getId(), ['body' => ['socialNetwork' => ['facebook' => '"']]]);
154152
$this->assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
155153
}
156-
157154
}

0 commit comments

Comments
 (0)