|
@@ -132,4 +132,153 @@ class HomeControllerTest extends FunctionalTest
|
132
|
132
|
}
|
133
|
133
|
}
|
134
|
134
|
|
|
135
|
+ /**
|
|
136
|
+ * Ajouts d'éléments et tests de cas refusés
|
|
137
|
+ */
|
|
138
|
+ public function testAddElementSuccess()
|
|
139
|
+ {
|
|
140
|
+ $this->connectUser('bux', 'toor');
|
|
141
|
+
|
|
142
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
143
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
144
|
+
|
|
145
|
+ // Un groupe open
|
|
146
|
+ $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
147
|
+
|
|
148
|
+ /*
|
|
149
|
+ * Ajout d'un élément avec succés
|
|
150
|
+ */
|
|
151
|
+ $this->procedure_add_element(
|
|
152
|
+ 'Mon bel element',
|
|
153
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
154
|
+ array($hardtek->getId(), $tribe->getId())
|
|
155
|
+ );
|
|
156
|
+
|
|
157
|
+ $this->isResponseRedirection();
|
|
158
|
+ $this->followRedirection();
|
|
159
|
+ $this->isResponseSuccess();
|
|
160
|
+
|
|
161
|
+ $this->exist('li:contains("Mon bel element")');
|
|
162
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
163
|
+ ->findOneByName('Mon bel element')
|
|
164
|
+ ;
|
|
165
|
+ $this->assertTrue(!is_null($element));
|
|
166
|
+
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ /**
|
|
170
|
+ * Ajouts d'éléments et tests de cas refusés
|
|
171
|
+ */
|
|
172
|
+ public function testAddElementFailure()
|
|
173
|
+ {
|
|
174
|
+ $this->connectUser('bux', 'toor');
|
|
175
|
+
|
|
176
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
177
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
178
|
+
|
|
179
|
+ // Un groupe no open
|
|
180
|
+ $dudeldrum = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('DUDELDRUM');
|
|
181
|
+
|
|
182
|
+ /*
|
|
183
|
+ * Ajouts d'éléments avec echec
|
|
184
|
+ */
|
|
185
|
+
|
|
186
|
+ // Nom trop court
|
|
187
|
+ $this->procedure_add_element(
|
|
188
|
+ 'Mo',
|
|
189
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
190
|
+ array($hardtek->getId(), $tribe->getId())
|
|
191
|
+ );
|
|
192
|
+
|
|
193
|
+ $this->isResponseSuccess();
|
|
194
|
+
|
|
195
|
+ $this->notExist('li:contains("Mon bel element")');
|
|
196
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
197
|
+ ->findOneByName('Mon bel element')
|
|
198
|
+ ;
|
|
199
|
+ $this->assertTrue(is_null($element));
|
|
200
|
+
|
|
201
|
+ // Nom trop long
|
|
202
|
+ $this->procedure_add_element(
|
|
203
|
+ 'Mon bel element mais qui a un nom trop court la vache oui trop long hohoho',
|
|
204
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
205
|
+ array($hardtek->getId(), $tribe->getId())
|
|
206
|
+ );
|
|
207
|
+
|
|
208
|
+ $this->isResponseSuccess();
|
|
209
|
+
|
|
210
|
+ $this->notExist('li:contains("Mon bel element mais qui a un nom trop court la vache oui trop long hohoho")');
|
|
211
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
212
|
+ ->findOneByName('Mon bel element mais qui a un nom trop court la vache oui trop long hohoho')
|
|
213
|
+ ;
|
|
214
|
+ $this->assertTrue(is_null($element));
|
|
215
|
+
|
|
216
|
+ // Pas d'url
|
|
217
|
+ $this->procedure_add_element(
|
|
218
|
+ 'Mon bel element',
|
|
219
|
+ '',
|
|
220
|
+ array($hardtek->getId(), $tribe->getId())
|
|
221
|
+ );
|
|
222
|
+
|
|
223
|
+ $this->isResponseSuccess();
|
|
224
|
+
|
|
225
|
+ $this->notExist('li:contains("Mon bel element")');
|
|
226
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
227
|
+ ->findOneByName('Mon bel element')
|
|
228
|
+ ;
|
|
229
|
+ $this->assertTrue(is_null($element));
|
|
230
|
+
|
|
231
|
+ // Pas de nom
|
|
232
|
+ $this->procedure_add_element(
|
|
233
|
+ '',
|
|
234
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
235
|
+ array($hardtek->getId(), $tribe->getId())
|
|
236
|
+ );
|
|
237
|
+
|
|
238
|
+ $this->isResponseSuccess();
|
|
239
|
+
|
|
240
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
241
|
+ ->findOneByName('')
|
|
242
|
+ ;
|
|
243
|
+ $this->assertTrue(is_null($element));
|
|
244
|
+
|
|
245
|
+ }
|
|
246
|
+
|
|
247
|
+ public function testAddElementAtGroupFailure()
|
|
248
|
+ {
|
|
249
|
+ $this->connectUser('bux', 'toor');
|
|
250
|
+
|
|
251
|
+ /*
|
|
252
|
+ * Ajout d'un élément lié a un groupe (success)
|
|
253
|
+ */
|
|
254
|
+ $this->procedure_add_element(
|
|
255
|
+ 'Mon bel element',
|
|
256
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
257
|
+ array($hardtek->getId(), $tribe->getId()),
|
|
258
|
+ $fan_de_psy->getId()
|
|
259
|
+ );
|
|
260
|
+
|
|
261
|
+ $this->isResponseRedirection();
|
|
262
|
+ $this->followRedirection();
|
|
263
|
+ $this->isResponseSuccess();
|
|
264
|
+
|
|
265
|
+ $this->exist('li:contains("Mon bel element")');
|
|
266
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
267
|
+ ->findOneByName('Mon bel element')
|
|
268
|
+ ;
|
|
269
|
+ $this->assertTrue(!is_null($element));
|
|
270
|
+ if (!is_null($element))
|
|
271
|
+ {
|
|
272
|
+ $this->assertEquals($fan_de_psy->getId(), $element->getGroup()->getId());
|
|
273
|
+ }
|
|
274
|
+ }
|
|
275
|
+
|
|
276
|
+ /**
|
|
277
|
+ * L'ajout d'un Element a un de ses groupe ne doit pas poser de problème
|
|
278
|
+ */
|
|
279
|
+ public function testAddElementAtMyGroupSuccess()
|
|
280
|
+ {
|
|
281
|
+
|
|
282
|
+ }
|
|
283
|
+
|
135
|
284
|
}
|