|
@@ -15,385 +15,385 @@ class HomeControllerTest extends FunctionalTest
|
15
|
15
|
{
|
16
|
16
|
$this->client = self::createClient();
|
17
|
17
|
$this->connectUser('bux', 'toor');
|
18
|
|
-//
|
19
|
|
-// // Présence du formulaire d'ajout d'un élément
|
20
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl('element_add')).'"]');
|
21
|
|
-// $this->exist('form[action="'.$url.'"] input[id="element_add_name"]');
|
22
|
|
-// $this->exist('form[action="'.$url.'"] input[id="element_add_url"]');
|
23
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
24
|
|
-//
|
25
|
|
-// // Présence du formulaire de filtrage
|
26
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl('search_elements')).'"]');
|
27
|
|
-// $this->exist('form[action="'.$url.'"] select[id="element_search_form_network"]');
|
28
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
29
|
|
-//
|
30
|
|
-// $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
31
|
|
-// $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
32
|
|
-//
|
33
|
|
-// // On récupére le formulaire de filtrage
|
34
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
35
|
|
-//
|
36
|
|
-// // On décoche les tags
|
37
|
|
-// foreach ($this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findAll() as $tag)
|
38
|
|
-// {
|
39
|
|
-// $form['element_search_form[tags]['.$tag->getId().']']->untick();
|
40
|
|
-// }
|
41
|
|
-//
|
42
|
|
-// // On met ce que l'on veut dans le form
|
43
|
|
-// $form['element_search_form[network]'] = ElementSearcher::NETWORK_PUBLIC;
|
44
|
|
-// $form['element_search_form[tags]['.$hardtek_id.']'] = $hardtek_id;
|
45
|
|
-// $form['element_search_form[tags]['.$tribe_id.']'] = $tribe_id;
|
46
|
|
-// $this->submit($form);
|
47
|
|
-//
|
48
|
|
-// $this->client->submit($form);
|
49
|
|
-//
|
50
|
|
-// $this->isResponseRedirection();
|
51
|
|
-// $this->followRedirection();
|
52
|
|
-// $this->isResponseSuccess();
|
53
|
|
-//
|
54
|
|
-// $this->assertTrue($this->getSession()->has('user.element_search.params'));
|
55
|
|
-// $this->assertEquals(array(
|
56
|
|
-// 'network' => ElementSearcher::NETWORK_PUBLIC,
|
57
|
|
-// 'tags' => array(
|
58
|
|
-// $hardtek_id, $tribe_id
|
59
|
|
-// ),
|
60
|
|
-// 'count' => $this->getContainer()->getParameter('search_default_count'),
|
61
|
|
-// 'user_id' => null,
|
62
|
|
-// 'group_id' => null,
|
63
|
|
-// 'favorite' => false
|
64
|
|
-// ), $this->getSession()->get('user.element_search.params'));
|
65
|
|
-//
|
66
|
|
-// // On fabrique l'ElementSearcher correspondant
|
67
|
|
-// $es = new ElementSearcher();
|
68
|
|
-// $es->init($this->getSession()->get('user.element_search.params'));
|
69
|
|
-//
|
70
|
|
-// foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
71
|
|
-// {
|
72
|
|
-// $this->exist('html:contains("'.$element->getName().'")');
|
73
|
|
-// }
|
|
18
|
+
|
|
19
|
+ // Présence du formulaire d'ajout d'un élément
|
|
20
|
+ $this->exist('form[action="'.($url = $this->generateUrl('element_add')).'"]');
|
|
21
|
+ $this->exist('form[action="'.$url.'"] input[id="element_add_name"]');
|
|
22
|
+ $this->exist('form[action="'.$url.'"] input[id="element_add_url"]');
|
|
23
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
24
|
+
|
|
25
|
+ // Présence du formulaire de filtrage
|
|
26
|
+ $this->exist('form[action="'.($url = $this->generateUrl('search_elements')).'"]');
|
|
27
|
+ $this->exist('form[action="'.$url.'"] select[id="element_search_form_network"]');
|
|
28
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
29
|
+
|
|
30
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
31
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
32
|
+
|
|
33
|
+ // On récupére le formulaire de filtrage
|
|
34
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
35
|
+
|
|
36
|
+ // On décoche les tags
|
|
37
|
+ foreach ($this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findAll() as $tag)
|
|
38
|
+ {
|
|
39
|
+ $form['element_search_form[tags]['.$tag->getId().']']->untick();
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ // On met ce que l'on veut dans le form
|
|
43
|
+ $form['element_search_form[network]'] = ElementSearcher::NETWORK_PUBLIC;
|
|
44
|
+ $form['element_search_form[tags]['.$hardtek_id.']'] = $hardtek_id;
|
|
45
|
+ $form['element_search_form[tags]['.$tribe_id.']'] = $tribe_id;
|
|
46
|
+ $this->submit($form);
|
|
47
|
+
|
|
48
|
+ $this->client->submit($form);
|
|
49
|
+
|
|
50
|
+ $this->isResponseRedirection();
|
|
51
|
+ $this->followRedirection();
|
|
52
|
+ $this->isResponseSuccess();
|
|
53
|
+
|
|
54
|
+ $this->assertTrue($this->getSession()->has('user.element_search.params'));
|
|
55
|
+ $this->assertEquals(array(
|
|
56
|
+ 'network' => ElementSearcher::NETWORK_PUBLIC,
|
|
57
|
+ 'tags' => array(
|
|
58
|
+ $hardtek_id, $tribe_id
|
|
59
|
+ ),
|
|
60
|
+ 'count' => $this->getContainer()->getParameter('search_default_count'),
|
|
61
|
+ 'user_id' => null,
|
|
62
|
+ 'group_id' => null,
|
|
63
|
+ 'favorite' => false
|
|
64
|
+ ), $this->getSession()->get('user.element_search.params'));
|
|
65
|
+
|
|
66
|
+ // On fabrique l'ElementSearcher correspondant
|
|
67
|
+ $es = new ElementSearcher();
|
|
68
|
+ $es->init($this->getSession()->get('user.element_search.params'));
|
|
69
|
+
|
|
70
|
+ foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
|
71
|
+ {
|
|
72
|
+ $this->exist('html:contains("'.$element->getName().'")');
|
|
73
|
+ }
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ /**
|
|
77
|
+ * Test de la présence des elements sur la page d'un utilisateur
|
|
78
|
+ */
|
|
79
|
+ public function testUserPage()
|
|
80
|
+ {
|
|
81
|
+ $this->client = self::createClient();
|
|
82
|
+ $this->connectUser('bux', 'toor');
|
|
83
|
+ $jean = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
|
|
84
|
+ ->findOneByUsername('jean')
|
|
85
|
+ ;
|
|
86
|
+
|
|
87
|
+ $this->crawler = $this->client->request(
|
|
88
|
+ 'GET',
|
|
89
|
+ $this->generateUrl('show_user', array('slug' => $jean->getSlug()))
|
|
90
|
+ );
|
|
91
|
+
|
|
92
|
+ $this->isResponseSuccess();
|
|
93
|
+ $this->exist('h2:contains("'.$jean->getName().'")');
|
|
94
|
+
|
|
95
|
+ $es = new ElementSearcher();
|
|
96
|
+ $es->init(array(
|
|
97
|
+ 'user_id' => $jean->getId()
|
|
98
|
+ ));
|
|
99
|
+
|
|
100
|
+ foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
|
101
|
+ {
|
|
102
|
+ $this->exist('html:contains("'.$element->getName().'")');
|
|
103
|
+ }
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ /**
|
|
107
|
+ * Test de la présence des elements sur la page d'un utilisateur
|
|
108
|
+ */
|
|
109
|
+ public function testGroupPage()
|
|
110
|
+ {
|
|
111
|
+ $this->client = self::createClient();
|
|
112
|
+ $this->connectUser('bux', 'toor');
|
|
113
|
+ $fdp = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
|
114
|
+ ->findOneBySlug('fans-de-psytrance')
|
|
115
|
+ ->getSingleResult()
|
|
116
|
+ ;
|
|
117
|
+
|
|
118
|
+ $this->crawler = $this->client->request(
|
|
119
|
+ 'GET',
|
|
120
|
+ $this->generateUrl('show_group', array('slug' => $fdp->getSlug()))
|
|
121
|
+ );
|
|
122
|
+
|
|
123
|
+ $this->isResponseSuccess();
|
|
124
|
+ $this->exist('h2:contains("'.$fdp->getName().'")');
|
|
125
|
+
|
|
126
|
+ $es = new ElementSearcher();
|
|
127
|
+ $es->init(array(
|
|
128
|
+ 'group_id' => $fdp->getId()
|
|
129
|
+ ));
|
|
130
|
+
|
|
131
|
+ foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
|
132
|
+ {
|
|
133
|
+ $this->exist('html:contains("'.$element->getName().'")');
|
|
134
|
+ }
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ /**
|
|
138
|
+ * Ajouts d'éléments et tests de cas refusés
|
|
139
|
+ */
|
|
140
|
+ public function testAddElementSuccess()
|
|
141
|
+ {
|
|
142
|
+ $this->client = self::createClient();
|
|
143
|
+ $this->connectUser('bux', 'toor');
|
|
144
|
+
|
|
145
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
146
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
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
|
+
|
74
|
167
|
}
|
75
|
168
|
|
76
|
|
-// /**
|
77
|
|
-// * Test de la présence des elements sur la page d'un utilisateur
|
78
|
|
-// */
|
79
|
|
-// public function testUserPage()
|
80
|
|
-// {
|
81
|
|
-// $this->client = self::createClient();
|
82
|
|
-// $this->connectUser('bux', 'toor');
|
83
|
|
-// $jean = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
|
84
|
|
-// ->findOneByUsername('jean')
|
85
|
|
-// ;
|
86
|
|
-//
|
87
|
|
-// $this->crawler = $this->client->request(
|
88
|
|
-// 'GET',
|
89
|
|
-// $this->generateUrl('show_user', array('slug' => $jean->getSlug()))
|
90
|
|
-// );
|
91
|
|
-//
|
92
|
|
-// $this->isResponseSuccess();
|
93
|
|
-// $this->exist('h2:contains("'.$jean->getName().'")');
|
94
|
|
-//
|
95
|
|
-// $es = new ElementSearcher();
|
96
|
|
-// $es->init(array(
|
97
|
|
-// 'user_id' => $jean->getId()
|
98
|
|
-// ));
|
99
|
|
-//
|
100
|
|
-// foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
101
|
|
-// {
|
102
|
|
-// $this->exist('html:contains("'.$element->getName().'")');
|
103
|
|
-// }
|
104
|
|
-// }
|
105
|
|
-//
|
106
|
|
-// /**
|
107
|
|
-// * Test de la présence des elements sur la page d'un utilisateur
|
108
|
|
-// */
|
109
|
|
-// public function testGroupPage()
|
110
|
|
-// {
|
111
|
|
-// $this->client = self::createClient();
|
112
|
|
-// $this->connectUser('bux', 'toor');
|
113
|
|
-// $fdp = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
114
|
|
-// ->findOneBySlug('fans-de-psytrance')
|
115
|
|
-// ->getSingleResult()
|
116
|
|
-// ;
|
117
|
|
-//
|
118
|
|
-// $this->crawler = $this->client->request(
|
119
|
|
-// 'GET',
|
120
|
|
-// $this->generateUrl('show_group', array('slug' => $fdp->getSlug()))
|
121
|
|
-// );
|
122
|
|
-//
|
123
|
|
-// $this->isResponseSuccess();
|
124
|
|
-// $this->exist('h2:contains("'.$fdp->getName().'")');
|
125
|
|
-//
|
126
|
|
-// $es = new ElementSearcher();
|
127
|
|
-// $es->init(array(
|
128
|
|
-// 'group_id' => $fdp->getId()
|
129
|
|
-// ));
|
130
|
|
-//
|
131
|
|
-// foreach ($es->getElements($this->getDoctrine(), $this->getUser()->getId()) as $element)
|
132
|
|
-// {
|
133
|
|
-// $this->exist('html:contains("'.$element->getName().'")');
|
134
|
|
-// }
|
135
|
|
-// }
|
136
|
|
-//
|
137
|
|
-// /**
|
138
|
|
-// * Ajouts d'éléments et tests de cas refusés
|
139
|
|
-// */
|
140
|
|
-// public function testAddElementSuccess()
|
141
|
|
-// {
|
142
|
|
-// $this->client = self::createClient();
|
143
|
|
-// $this->connectUser('bux', 'toor');
|
144
|
|
-//
|
145
|
|
-// $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
146
|
|
-// $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
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->client = self::createClient();
|
175
|
|
-// $this->connectUser('bux', 'toor');
|
176
|
|
-//
|
177
|
|
-// $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
178
|
|
-// $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
179
|
|
-//
|
180
|
|
-// /*
|
181
|
|
-// * Ajouts d'éléments avec echec
|
182
|
|
-// */
|
183
|
|
-//
|
184
|
|
-// // Nom trop court
|
185
|
|
-// $this->procedure_add_element(
|
186
|
|
-// 'Mo',
|
187
|
|
-// 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
188
|
|
-// array($hardtek->getId(), $tribe->getId())
|
189
|
|
-// );
|
190
|
|
-//
|
191
|
|
-// $this->isResponseSuccess();
|
192
|
|
-//
|
193
|
|
-// $this->notExist('li:contains("Mon bel element a4er563a1r")');
|
194
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
195
|
|
-// ->findOneByName('Mon bel element a4er563a1r')
|
196
|
|
-// ;
|
197
|
|
-// $this->assertTrue(is_null($element));
|
198
|
|
-//
|
199
|
|
-// // Nom trop long
|
200
|
|
-// $this->procedure_add_element(
|
201
|
|
-// 'Mon bel element mais qui a un nom trop court la vache oui trop long hohoho',
|
202
|
|
-// 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
203
|
|
-// array($hardtek->getId(), $tribe->getId())
|
204
|
|
-// );
|
205
|
|
-//
|
206
|
|
-// $this->isResponseSuccess();
|
207
|
|
-//
|
208
|
|
-// $this->notExist('li:contains("Mon bel element mais qui a un nom trop court la vache oui trop long hohoho")');
|
209
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
210
|
|
-// ->findOneByName('Mon bel element mais qui a un nom trop court la vache oui trop long hohoho')
|
211
|
|
-// ;
|
212
|
|
-// $this->assertTrue(is_null($element));
|
213
|
|
-//
|
214
|
|
-// // Pas d'url
|
215
|
|
-// $this->procedure_add_element(
|
216
|
|
-// 'Mon bel element',
|
217
|
|
-// '',
|
218
|
|
-// array($hardtek->getId(), $tribe->getId())
|
219
|
|
-// );
|
220
|
|
-//
|
221
|
|
-// $this->isResponseSuccess();
|
222
|
|
-//
|
223
|
|
-// $this->notExist('li:contains("Mon bel element gfez7f")');
|
224
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
225
|
|
-// ->findOneByName('Mon bel element gfez7f')
|
226
|
|
-// ;
|
227
|
|
-// $this->assertTrue(is_null($element));
|
228
|
|
-//
|
229
|
|
-// // url non conforme
|
230
|
|
-// $this->procedure_add_element(
|
231
|
|
-// 'Mon bel element 789e',
|
232
|
|
-// 'http://',
|
233
|
|
-// array($hardtek->getId(), $tribe->getId())
|
234
|
|
-// );
|
235
|
|
-//
|
236
|
|
-// $this->isResponseSuccess();
|
237
|
|
-//
|
238
|
|
-// $this->notExist('li:contains("Mon bel element 789e")');
|
239
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
240
|
|
-// ->findOneByName('Mon bel element 789e')
|
241
|
|
-// ;
|
242
|
|
-// $this->assertTrue(is_null($element));
|
243
|
|
-//
|
244
|
|
-// // url non conforme
|
245
|
|
-// $this->procedure_add_element(
|
246
|
|
-// 'Mon bel element 789f',
|
247
|
|
-// 'http://youtube',
|
248
|
|
-// array($hardtek->getId(), $tribe->getId())
|
249
|
|
-// );
|
250
|
|
-//
|
251
|
|
-// $this->isResponseSuccess();
|
252
|
|
-//
|
253
|
|
-// $this->notExist('li:contains("Mon bel element 789f")');
|
254
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
255
|
|
-// ->findOneByName('Mon bel element 789f')
|
256
|
|
-// ;
|
257
|
|
-// $this->assertTrue(is_null($element));
|
258
|
|
-//
|
259
|
|
-// // url non conforme
|
260
|
|
-// $this->procedure_add_element(
|
261
|
|
-// 'Mon bel element 789g',
|
262
|
|
-// 'youtube.com?lalala',
|
263
|
|
-// array($hardtek->getId(), $tribe->getId())
|
264
|
|
-// );
|
265
|
|
-//
|
266
|
|
-// $this->isResponseSuccess();
|
267
|
|
-//
|
268
|
|
-// $this->notExist('li:contains("Mon bel element 789g")');
|
269
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
270
|
|
-// ->findOneByName('Mon bel element 789g')
|
271
|
|
-// ;
|
272
|
|
-// $this->assertTrue(is_null($element));
|
273
|
|
-//
|
274
|
|
-// // Pas de nom
|
275
|
|
-// $this->procedure_add_element(
|
276
|
|
-// '',
|
277
|
|
-// 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
278
|
|
-// array($hardtek->getId(), $tribe->getId())
|
279
|
|
-// );
|
280
|
|
-//
|
281
|
|
-// $this->isResponseSuccess();
|
282
|
|
-//
|
283
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
284
|
|
-// ->findOneByName('')
|
285
|
|
-// ;
|
286
|
|
-// $this->assertTrue(is_null($element));
|
287
|
|
-//
|
288
|
|
-// }
|
289
|
|
-//
|
290
|
|
-// /**
|
291
|
|
-// * L'ajout d'un Element a un de ses groupe ne doit pas poser de problème
|
292
|
|
-// */
|
293
|
|
-// public function testAddElementAtMyGroupSuccess()
|
294
|
|
-// {
|
295
|
|
-// $this->client = self::createClient();
|
296
|
|
-// $this->connectUser('bux', 'toor');
|
297
|
|
-// // Un groupe open, donc pas de soucis
|
298
|
|
-// $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
299
|
|
-//
|
300
|
|
-// $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
301
|
|
-// $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
302
|
|
-//
|
303
|
|
-// $this->isResponseSuccess();
|
304
|
|
-// $this->procedure_add_element(
|
305
|
|
-// 'Element mis dans le groupe de psytrance',
|
306
|
|
-// 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
307
|
|
-// array($hardtek->getId(), $tribe->getId()),
|
308
|
|
-// $fan_de_psy->getSlug()
|
309
|
|
-// );
|
310
|
|
-//
|
311
|
|
-// $this->isResponseRedirection();
|
312
|
|
-// $this->followRedirection();
|
313
|
|
-// $this->isResponseSuccess();
|
314
|
|
-//
|
315
|
|
-// $this->exist('li:contains("Element mis dans le groupe de psytrance")');
|
316
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
317
|
|
-// ->findOneByName('Element mis dans le groupe de psytrance')
|
318
|
|
-// ;
|
319
|
|
-// $this->assertTrue(!is_null($element));
|
320
|
|
-//
|
321
|
|
-// if (!is_null($element))
|
322
|
|
-// {
|
323
|
|
-// $this->assertEquals($fan_de_psy->getId(), $element->getGroup()->getId());
|
324
|
|
-// }
|
325
|
|
-// else
|
326
|
|
-// {
|
327
|
|
-// $this->assertTrue(false);
|
328
|
|
-// }
|
329
|
|
-//
|
330
|
|
-// $this->disconnectUser();
|
331
|
|
-//
|
332
|
|
-// /*
|
333
|
|
-// * Ajout d'un element dans un groupe que l'on posséde.
|
334
|
|
-// */
|
335
|
|
-// $this->client = self::createClient();
|
336
|
|
-// $this->connectUser('joelle', 'toor');
|
337
|
|
-// $this->isResponseSuccess();
|
338
|
|
-//
|
339
|
|
-// // Ce groupe appartient a joelle
|
340
|
|
-// $groupe_de_joelle = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Le groupe de joelle');
|
341
|
|
-//
|
342
|
|
-// $this->procedure_add_element(
|
343
|
|
-// 'Element mis dans le groupe de joelle',
|
344
|
|
-// 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
345
|
|
-// array($hardtek->getId(), $tribe->getId()),
|
346
|
|
-// $groupe_de_joelle->getSlug()
|
347
|
|
-// );
|
348
|
|
-//
|
349
|
|
-// $this->isResponseRedirection();
|
350
|
|
-// $this->followRedirection();
|
351
|
|
-// $this->isResponseSuccess();
|
352
|
|
-//
|
353
|
|
-// $this->exist('li:contains("Element mis dans le groupe de joelle")');
|
354
|
|
-// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
355
|
|
-// ->findOneByName('Element mis dans le groupe de joelle')
|
356
|
|
-// ;
|
357
|
|
-// $this->assertTrue(!is_null($element));
|
358
|
|
-//
|
359
|
|
-// if (!is_null($element))
|
360
|
|
-// {
|
361
|
|
-// $this->assertEquals($groupe_de_joelle->getId(), $element->getGroup()->getId());
|
362
|
|
-// }
|
363
|
|
-// else
|
364
|
|
-// {
|
365
|
|
-// $this->assertTrue(false);
|
366
|
|
-// }
|
367
|
|
-// }
|
368
|
|
-//
|
369
|
|
-// /**
|
370
|
|
-// * L'ajout a un group qui n'est pas a sois, ou qui n'est pas open
|
371
|
|
-// * doit être impossible.
|
372
|
|
-// */
|
373
|
|
-// public function testAddElementAtGroupFailure()
|
374
|
|
-// {
|
375
|
|
-// $this->client = self::createClient();
|
376
|
|
-// $this->connectUser('bux', 'toor');
|
377
|
|
-// // Un groupe no open
|
378
|
|
-// $dudeldrum = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('DUDELDRUM');
|
379
|
|
-//
|
380
|
|
-// $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
381
|
|
-// $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
382
|
|
-//
|
383
|
|
-// // Nous tentons d'ouvrir l'url d'ajout d'élément avec un groupe qui n'est pas ouvert
|
384
|
|
-// // et qui n'appartient pas a l'utilisateur connecté
|
385
|
|
-// $this->crawler = $this->client->request(
|
386
|
|
-// 'POST',
|
387
|
|
-// $this->generateUrl('element_add', array('group_slug' => $dudeldrum->getSlug())),
|
388
|
|
-// array(
|
389
|
|
-// 'element_add[name]' => 'Yohoho trululu',
|
390
|
|
-// 'element_add[url]' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
391
|
|
-// 'element_add[tags]['.$hardtek->getId().']' => $hardtek->getId(),
|
392
|
|
-// 'element_add[tags]['.$tribe->getId().']' => $tribe->getId()
|
393
|
|
-// )
|
394
|
|
-// );
|
395
|
|
-//
|
396
|
|
-// $this->isResponseNotFound();
|
397
|
|
-// }
|
|
169
|
+ /**
|
|
170
|
+ * Ajouts d'éléments et tests de cas refusés
|
|
171
|
+ */
|
|
172
|
+ public function testAddElementFailure()
|
|
173
|
+ {
|
|
174
|
+ $this->client = self::createClient();
|
|
175
|
+ $this->connectUser('bux', 'toor');
|
|
176
|
+
|
|
177
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
178
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
179
|
+
|
|
180
|
+ /*
|
|
181
|
+ * Ajouts d'éléments avec echec
|
|
182
|
+ */
|
|
183
|
+
|
|
184
|
+ // Nom trop court
|
|
185
|
+ $this->procedure_add_element(
|
|
186
|
+ 'Mo',
|
|
187
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
188
|
+ array($hardtek->getId(), $tribe->getId())
|
|
189
|
+ );
|
|
190
|
+
|
|
191
|
+ $this->isResponseSuccess();
|
|
192
|
+
|
|
193
|
+ $this->notExist('li:contains("Mon bel element a4er563a1r")');
|
|
194
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
195
|
+ ->findOneByName('Mon bel element a4er563a1r')
|
|
196
|
+ ;
|
|
197
|
+ $this->assertTrue(is_null($element));
|
|
198
|
+
|
|
199
|
+ // Nom trop long
|
|
200
|
+ $this->procedure_add_element(
|
|
201
|
+ 'Mon bel element mais qui a un nom trop court la vache oui trop long hohoho',
|
|
202
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
203
|
+ array($hardtek->getId(), $tribe->getId())
|
|
204
|
+ );
|
|
205
|
+
|
|
206
|
+ $this->isResponseSuccess();
|
|
207
|
+
|
|
208
|
+ $this->notExist('li:contains("Mon bel element mais qui a un nom trop court la vache oui trop long hohoho")');
|
|
209
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
210
|
+ ->findOneByName('Mon bel element mais qui a un nom trop court la vache oui trop long hohoho')
|
|
211
|
+ ;
|
|
212
|
+ $this->assertTrue(is_null($element));
|
|
213
|
+
|
|
214
|
+ // Pas d'url
|
|
215
|
+ $this->procedure_add_element(
|
|
216
|
+ 'Mon bel element',
|
|
217
|
+ '',
|
|
218
|
+ array($hardtek->getId(), $tribe->getId())
|
|
219
|
+ );
|
|
220
|
+
|
|
221
|
+ $this->isResponseSuccess();
|
|
222
|
+
|
|
223
|
+ $this->notExist('li:contains("Mon bel element gfez7f")');
|
|
224
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
225
|
+ ->findOneByName('Mon bel element gfez7f')
|
|
226
|
+ ;
|
|
227
|
+ $this->assertTrue(is_null($element));
|
|
228
|
+
|
|
229
|
+ // url non conforme
|
|
230
|
+ $this->procedure_add_element(
|
|
231
|
+ 'Mon bel element 789e',
|
|
232
|
+ 'http://',
|
|
233
|
+ array($hardtek->getId(), $tribe->getId())
|
|
234
|
+ );
|
|
235
|
+
|
|
236
|
+ $this->isResponseSuccess();
|
|
237
|
+
|
|
238
|
+ $this->notExist('li:contains("Mon bel element 789e")');
|
|
239
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
240
|
+ ->findOneByName('Mon bel element 789e')
|
|
241
|
+ ;
|
|
242
|
+ $this->assertTrue(is_null($element));
|
|
243
|
+
|
|
244
|
+ // url non conforme
|
|
245
|
+ $this->procedure_add_element(
|
|
246
|
+ 'Mon bel element 789f',
|
|
247
|
+ 'http://youtube',
|
|
248
|
+ array($hardtek->getId(), $tribe->getId())
|
|
249
|
+ );
|
|
250
|
+
|
|
251
|
+ $this->isResponseSuccess();
|
|
252
|
+
|
|
253
|
+ $this->notExist('li:contains("Mon bel element 789f")');
|
|
254
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
255
|
+ ->findOneByName('Mon bel element 789f')
|
|
256
|
+ ;
|
|
257
|
+ $this->assertTrue(is_null($element));
|
|
258
|
+
|
|
259
|
+ // url non conforme
|
|
260
|
+ $this->procedure_add_element(
|
|
261
|
+ 'Mon bel element 789g',
|
|
262
|
+ 'youtube.com?lalala',
|
|
263
|
+ array($hardtek->getId(), $tribe->getId())
|
|
264
|
+ );
|
|
265
|
+
|
|
266
|
+ $this->isResponseSuccess();
|
|
267
|
+
|
|
268
|
+ $this->notExist('li:contains("Mon bel element 789g")');
|
|
269
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
270
|
+ ->findOneByName('Mon bel element 789g')
|
|
271
|
+ ;
|
|
272
|
+ $this->assertTrue(is_null($element));
|
|
273
|
+
|
|
274
|
+ // Pas de nom
|
|
275
|
+ $this->procedure_add_element(
|
|
276
|
+ '',
|
|
277
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
278
|
+ array($hardtek->getId(), $tribe->getId())
|
|
279
|
+ );
|
|
280
|
+
|
|
281
|
+ $this->isResponseSuccess();
|
|
282
|
+
|
|
283
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
284
|
+ ->findOneByName('')
|
|
285
|
+ ;
|
|
286
|
+ $this->assertTrue(is_null($element));
|
|
287
|
+
|
|
288
|
+ }
|
|
289
|
+
|
|
290
|
+ /**
|
|
291
|
+ * L'ajout d'un Element a un de ses groupe ne doit pas poser de problème
|
|
292
|
+ */
|
|
293
|
+ public function testAddElementAtMyGroupSuccess()
|
|
294
|
+ {
|
|
295
|
+ $this->client = self::createClient();
|
|
296
|
+ $this->connectUser('bux', 'toor');
|
|
297
|
+ // Un groupe open, donc pas de soucis
|
|
298
|
+ $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
299
|
+
|
|
300
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
301
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
302
|
+
|
|
303
|
+ $this->isResponseSuccess();
|
|
304
|
+ $this->procedure_add_element(
|
|
305
|
+ 'Element mis dans le groupe de psytrance',
|
|
306
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
307
|
+ array($hardtek->getId(), $tribe->getId()),
|
|
308
|
+ $fan_de_psy->getSlug()
|
|
309
|
+ );
|
|
310
|
+
|
|
311
|
+ $this->isResponseRedirection();
|
|
312
|
+ $this->followRedirection();
|
|
313
|
+ $this->isResponseSuccess();
|
|
314
|
+
|
|
315
|
+ $this->exist('li:contains("Element mis dans le groupe de psytrance")');
|
|
316
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
317
|
+ ->findOneByName('Element mis dans le groupe de psytrance')
|
|
318
|
+ ;
|
|
319
|
+ $this->assertTrue(!is_null($element));
|
|
320
|
+
|
|
321
|
+ if (!is_null($element))
|
|
322
|
+ {
|
|
323
|
+ $this->assertEquals($fan_de_psy->getId(), $element->getGroup()->getId());
|
|
324
|
+ }
|
|
325
|
+ else
|
|
326
|
+ {
|
|
327
|
+ $this->assertTrue(false);
|
|
328
|
+ }
|
|
329
|
+
|
|
330
|
+ $this->disconnectUser();
|
|
331
|
+
|
|
332
|
+ /*
|
|
333
|
+ * Ajout d'un element dans un groupe que l'on posséde.
|
|
334
|
+ */
|
|
335
|
+ $this->client = self::createClient();
|
|
336
|
+ $this->connectUser('joelle', 'toor');
|
|
337
|
+ $this->isResponseSuccess();
|
|
338
|
+
|
|
339
|
+ // Ce groupe appartient a joelle
|
|
340
|
+ $groupe_de_joelle = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Le groupe de joelle');
|
|
341
|
+
|
|
342
|
+ $this->procedure_add_element(
|
|
343
|
+ 'Element mis dans le groupe de joelle',
|
|
344
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
345
|
+ array($hardtek->getId(), $tribe->getId()),
|
|
346
|
+ $groupe_de_joelle->getSlug()
|
|
347
|
+ );
|
|
348
|
+
|
|
349
|
+ $this->isResponseRedirection();
|
|
350
|
+ $this->followRedirection();
|
|
351
|
+ $this->isResponseSuccess();
|
|
352
|
+
|
|
353
|
+ $this->exist('li:contains("Element mis dans le groupe de joelle")');
|
|
354
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
355
|
+ ->findOneByName('Element mis dans le groupe de joelle')
|
|
356
|
+ ;
|
|
357
|
+ $this->assertTrue(!is_null($element));
|
|
358
|
+
|
|
359
|
+ if (!is_null($element))
|
|
360
|
+ {
|
|
361
|
+ $this->assertEquals($groupe_de_joelle->getId(), $element->getGroup()->getId());
|
|
362
|
+ }
|
|
363
|
+ else
|
|
364
|
+ {
|
|
365
|
+ $this->assertTrue(false);
|
|
366
|
+ }
|
|
367
|
+ }
|
|
368
|
+
|
|
369
|
+ /**
|
|
370
|
+ * L'ajout a un group qui n'est pas a sois, ou qui n'est pas open
|
|
371
|
+ * doit être impossible.
|
|
372
|
+ */
|
|
373
|
+ public function testAddElementAtGroupFailure()
|
|
374
|
+ {
|
|
375
|
+ $this->client = self::createClient();
|
|
376
|
+ $this->connectUser('bux', 'toor');
|
|
377
|
+ // Un groupe no open
|
|
378
|
+ $dudeldrum = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('DUDELDRUM');
|
|
379
|
+
|
|
380
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
381
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
382
|
+
|
|
383
|
+ // Nous tentons d'ouvrir l'url d'ajout d'élément avec un groupe qui n'est pas ouvert
|
|
384
|
+ // et qui n'appartient pas a l'utilisateur connecté
|
|
385
|
+ $this->crawler = $this->client->request(
|
|
386
|
+ 'POST',
|
|
387
|
+ $this->generateUrl('element_add', array('group_slug' => $dudeldrum->getSlug())),
|
|
388
|
+ array(
|
|
389
|
+ 'element_add[name]' => 'Yohoho trululu',
|
|
390
|
+ 'element_add[url]' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
391
|
+ 'element_add[tags]['.$hardtek->getId().']' => $hardtek->getId(),
|
|
392
|
+ 'element_add[tags]['.$tribe->getId().']' => $tribe->getId()
|
|
393
|
+ )
|
|
394
|
+ );
|
|
395
|
+
|
|
396
|
+ $this->isResponseNotFound();
|
|
397
|
+ }
|
398
|
398
|
|
399
|
399
|
}
|