|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\KI\UserBundle\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Tests\KI\CoreBundle\WebTestCase; |
|
6
|
|
|
|
|
7
|
|
|
class ClubsControllerTest extends WebTestCase |
|
8
|
|
|
{ |
|
9
|
|
|
// On crée une ressource sur laquelle seront effectués les tests. Ne pas oublier de supprimer à la fin avec le test DELETE. |
|
10
|
|
|
public function testPost() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->client->request( |
|
13
|
|
|
'POST', '/clubs', [ |
|
14
|
|
|
'fullName' => 'Chasse Ponts Tradition', |
|
15
|
|
|
'name' => 'CPT', |
|
16
|
|
|
'administration' => true, |
|
17
|
|
|
'category' => 'club', |
|
18
|
|
|
'presentation' => 'La liste pipeau', |
|
19
|
|
|
'place' => 'Meunier', |
|
20
|
|
|
'open' => false |
|
21
|
|
|
] |
|
22
|
|
|
); |
|
23
|
|
|
$response = $this->client->getResponse(); |
|
24
|
|
|
$this->assertJsonResponse($response, 201); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testGet() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->client->request('GET', '/clubs'); |
|
30
|
|
|
$response = $this->client->getResponse(); |
|
31
|
|
|
$this->assertJsonResponse($response, 200); |
|
32
|
|
|
|
|
33
|
|
|
$this->client->request('GET', '/clubs/cpt'); |
|
34
|
|
|
$response = $this->client->getResponse(); |
|
35
|
|
|
$this->assertJsonResponse($response, 200); |
|
36
|
|
|
|
|
37
|
|
|
$this->client->request('GET', '/clubs/sjoajsiohaysahais-asbsksaba7'); |
|
38
|
|
|
$response = $this->client->getResponse(); |
|
39
|
|
|
$this->assertJsonResponse($response, 404); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
View Code Duplication |
public function testGetPublications() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->client->request('GET', '/clubs/cpt/events'); |
|
45
|
|
|
$response = $this->client->getResponse(); |
|
46
|
|
|
$this->assertJsonResponse($response, 200); |
|
47
|
|
|
|
|
48
|
|
|
$this->client->request('GET', '/clubs/cpt/newsitems'); |
|
49
|
|
|
$response = $this->client->getResponse(); |
|
50
|
|
|
$this->assertJsonResponse($response, 200); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
View Code Duplication |
public function testPatch() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->client->request( |
|
56
|
|
|
'PATCH', '/clubs/cpt', [ |
|
57
|
|
|
'image' => 'https://upload.wikimedia.org/wikipedia/commons/5/5a/Wikipedia-logo-v2-fr.png', |
|
58
|
|
|
'banner' => 'https://upload.wikimedia.org/wikipedia/commons/5/5a/Wikipedia-logo-v2-fr.png' |
|
59
|
|
|
] |
|
60
|
|
|
); |
|
61
|
|
|
$response = $this->client->getResponse(); |
|
62
|
|
|
$this->assertJsonResponse($response, 204); |
|
63
|
|
|
|
|
64
|
|
|
$this->client->request('PATCH', '/clubs/cpt', ['name' => '']); |
|
65
|
|
|
$response = $this->client->getResponse(); |
|
66
|
|
|
$this->assertJsonResponse($response, 400); |
|
67
|
|
|
|
|
68
|
|
|
$this->client->request('PATCH', '/clubs/sjoajsiosbsksaba7', ['name' => 'miam', 'mail' => '[email protected]']); |
|
69
|
|
|
$response = $this->client->getResponse(); |
|
70
|
|
|
$this->assertJsonResponse($response, 404); |
|
71
|
|
|
|
|
72
|
|
|
$this->client->request('PATCH', '/clubs/cpt', ['name' => 'miam', 'mail' => '[email protected]']); |
|
73
|
|
|
$response = $this->client->getResponse(); |
|
74
|
|
|
$this->assertJsonResponse($response, 400); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
// Tests relatifs aux membres |
|
80
|
|
|
|
|
81
|
|
|
public function testGetUser() |
|
82
|
|
|
{ |
|
83
|
|
|
$this->client->request('GET', '/clubs/cpt/users'); |
|
84
|
|
|
$response = $this->client->getResponse(); |
|
85
|
|
|
$this->assertJsonResponse($response, 200); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function testLink() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->client->request('POST', '/clubs/cpt/users/dziris', ['role' => '']); |
|
91
|
|
|
$response = $this->client->getResponse(); |
|
92
|
|
|
$this->assertJsonResponse($response, 400); |
|
93
|
|
|
|
|
94
|
|
|
$this->client->request('POST', '/clubs/cpt/users/dziris', ['role' => 'Test']); |
|
95
|
|
|
$response = $this->client->getResponse(); |
|
96
|
|
|
$this->assertJsonResponse($response, 204); |
|
97
|
|
|
|
|
98
|
|
|
$this->client->request('POST', '/clubs/cpt/users/trancara', ['role' => 'Test']); |
|
99
|
|
|
$response = $this->client->getResponse(); |
|
100
|
|
|
$this->assertJsonResponse($response, 204); |
|
101
|
|
|
|
|
102
|
|
|
$this->client->request('POST', '/clubs/cpt/users/dziris', ['role' => 'Test 2']); |
|
103
|
|
|
$response = $this->client->getResponse(); |
|
104
|
|
|
$this->assertJsonResponse($response, 400); |
|
105
|
|
|
|
|
106
|
|
|
$this->client->request('POST', '/clubs/fdxcyhjbj/users/dziris', ['role' => 'Test 2']); |
|
107
|
|
|
$response = $this->client->getResponse(); |
|
108
|
|
|
$this->assertJsonResponse($response, 404); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
View Code Duplication |
public function testLinkEdit() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->client->request('PATCH', '/clubs/cpt/users/dziris', ['role' => '']); |
|
114
|
|
|
$response = $this->client->getResponse(); |
|
115
|
|
|
$this->assertJsonResponse($response, 400); |
|
116
|
|
|
|
|
117
|
|
|
$this->client->request('PATCH', '/clubs/cpt/users/dziris', ['role' => 'Test 33']); |
|
118
|
|
|
$response = $this->client->getResponse(); |
|
119
|
|
|
$this->assertJsonResponse($response, 204); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function testUnlink() |
|
123
|
|
|
{ |
|
124
|
|
|
$this->client->request('DELETE', '/clubs/cpt/users/dziriqsqsqsss'); |
|
125
|
|
|
$response = $this->client->getResponse(); |
|
126
|
|
|
$this->assertJsonResponse($response, 404); |
|
127
|
|
|
|
|
128
|
|
|
$this->client->request('DELETE', '/clubs/ksdsddssdi/users/dziris'); |
|
129
|
|
|
$response = $this->client->getResponse(); |
|
130
|
|
|
$this->assertJsonResponse($response, 404); |
|
131
|
|
|
|
|
132
|
|
|
$this->client->request('DELETE', '/clubs/cpt/users/dziris'); |
|
133
|
|
|
$response = $this->client->getResponse(); |
|
134
|
|
|
$this->assertJsonResponse($response, 204); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
View Code Duplication |
public function testUnFollow() { |
|
138
|
|
|
$this->client->request('POST', '/clubs/cpt/unfollow'); |
|
139
|
|
|
$response = $this->client->getResponse(); |
|
140
|
|
|
$this->assertJsonResponse($response, 204); |
|
141
|
|
|
|
|
142
|
|
|
$this->client->request('POST', '/clubs/dqflkabereich/unfollow'); |
|
143
|
|
|
$response = $this->client->getResponse(); |
|
144
|
|
|
$this->assertJsonResponse($response, 404); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
View Code Duplication |
public function testFollow() { |
|
148
|
|
|
$this->client->request('POST', '/clubs/cpt/follow'); |
|
149
|
|
|
$response = $this->client->getResponse(); |
|
150
|
|
|
$this->assertJsonResponse($response, 204); |
|
151
|
|
|
|
|
152
|
|
|
$this->client->request('POST', '/clubs/dqflkabereich/follow'); |
|
153
|
|
|
$response = $this->client->getResponse(); |
|
154
|
|
|
$this->assertJsonResponse($response, 404); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
View Code Duplication |
public function testDelete() |
|
158
|
|
|
{ |
|
159
|
|
|
$this->client->request('DELETE', '/clubs/cpt'); |
|
160
|
|
|
$response = $this->client->getResponse(); |
|
161
|
|
|
$this->assertJsonResponse($response, 204); |
|
162
|
|
|
|
|
163
|
|
|
$this->client->request('DELETE', '/clubs/cpt'); |
|
164
|
|
|
$response = $this->client->getResponse(); |
|
165
|
|
|
$this->assertJsonResponse($response, 404); |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|