浏览代码

début des tests fonctionnels pour playlist

Bastien Sevajol 11 年前
父节点
当前提交
d8b47cccf3

+ 1 - 0
src/Muzich/CoreBundle/Resources/config/security.yml 查看文件

@@ -106,6 +106,7 @@ security:
106 106
         - { path: ^/(?:fr|en)/user, role: IS_AUTHENTICATED_ANONYMOUSLY }
107 107
         - { path: ^/(?:fr|en)/group, role: IS_AUTHENTICATED_ANONYMOUSLY }
108 108
         - { path: ^/(?:fr|en)/search, role: IS_AUTHENTICATED_ANONYMOUSLY }
109
+        - { path: ^/(?:fr|en)/playlist, role: IS_AUTHENTICATED_ANONYMOUSLY }
109 110
                                         
110 111
         - { path: ^/, roles: ROLE_USER }
111 112
         

+ 194 - 5
src/Muzich/CoreBundle/Tests/Controller/PlaylistControllerTest.php 查看文件

@@ -1,7 +1,196 @@
1 1
 <?php
2 2
 
3
-/*
4
- * To change this template, choose Tools | Templates
5
- * and open the template in the editor.
6
- */
7
-?>
3
+namespace Muzich\CoreBundle\Tests\Controller;
4
+
5
+use Muzich\CoreBundle\lib\FunctionalTest;
6
+use Muzich\CoreBundle\Tests\lib\Security\Context as SecurityContextTest;
7
+use Muzich\CoreBundle\Security\Context as SecurityContext;
8
+use Muzich\CoreBundle\Tests\lib\Security\ContextTestCases;
9
+
10
+class PlaylistControllerTest extends FunctionalTest
11
+{
12
+  
13
+  protected $security_context_test;
14
+  protected $tests_cases;
15
+  
16
+  protected function init()
17
+  {
18
+    $this->client = self::createClient();
19
+    $this->security_context_test = new SecurityContextTest($this->client, $this);
20
+    $this->tests_cases = new ContextTestCases($this->client, $this);
21
+  }
22
+  
23
+//  public function testActionsSecurityRoles()
24
+//  {
25
+//    $this->init();
26
+//    $this->checkProhibedActionsForAnonymous();
27
+//    $this->checkAutorizedsActionsForAnonymous();
28
+//  }
29
+  
30
+  protected function checkProhibedActionsForAnonymous()
31
+  {
32
+    $this->security_context_test->testUserCantMakeActionStatus( 
33
+      SecurityContext::ACTION_PLAYLIST_ADD_ELEMENT, 
34
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
35
+      true
36
+    );
37
+    
38
+    $this->security_context_test->testUserCantMakeActionStatus( 
39
+      SecurityContext::ACTION_PLAYLIST_UPDATE_ORDER, 
40
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
41
+      true
42
+    );
43
+    
44
+    $this->security_context_test->testUserCantMakeActionStatus( 
45
+      SecurityContext::ACTION_PLAYLIST_REMOVE_ELEMENT, 
46
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
47
+      true
48
+    );
49
+    
50
+    $this->security_context_test->testUserCantMakeActionStatus( 
51
+      SecurityContext::ACTION_PLAYLIST_CREATE, 
52
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
53
+      true
54
+    );
55
+    
56
+    $this->security_context_test->testUserCantMakeActionStatus( 
57
+      SecurityContext::ACTION_PLAYLIST_COPY, 
58
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
59
+      true
60
+    );
61
+    
62
+    $this->security_context_test->testUserCantMakeActionStatus( 
63
+      SecurityContext::ACTION_PLAYLIST_DELETE, 
64
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
65
+      true
66
+    );
67
+    
68
+    $this->security_context_test->testUserCantMakeActionStatus( 
69
+      SecurityContext::ACTION_PLAYLIST_UNPICK, 
70
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
71
+      true
72
+    );
73
+    
74
+    $this->security_context_test->testUserCantMakeActionStatus( 
75
+      SecurityContext::ACTION_PLAYLIST_PICK, 
76
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
77
+      true
78
+    );
79
+  }
80
+  
81
+  protected function checkAutorizedsActionsForAnonymous()
82
+  {
83
+    $this->security_context_test->testUserCantMakeActionStatus( 
84
+      SecurityContext::ACTION_PLAYLIST_SHOW, 
85
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
86
+      false
87
+    );
88
+    
89
+    $this->security_context_test->testUserCantMakeActionStatus( 
90
+      SecurityContext::ACTION_PLAYLIST_DATA_AUTOPLAY, 
91
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
92
+      false
93
+    );
94
+    
95
+    $this->security_context_test->testUserCantMakeActionStatus( 
96
+      SecurityContext::ACTION_PLAYLIST_ADD_PROMPT, 
97
+      SecurityContext::CONDITION_USER_NOT_CONNECTED,
98
+      false
99
+    );
100
+  }
101
+  
102
+//  public function testPlaylistsRead()
103
+//  {
104
+//    $this->init();
105
+//    $this->initReadContextData();
106
+//    
107
+//    $this->checkReadablePlaylistsForAnonymous();
108
+//    $this->checkReadablePlaylistsForConnected();
109
+//    $this->checkReadablePlaylistsForOwner();
110
+//  }
111
+  
112
+  protected function initReadContextData()
113
+  {
114
+    $this->users['bux'] = $this->findUserByUsername('bux');
115
+    $this->playlists['bux_1_pub'] = $this->findOneBy('Playlist', 'Un peu de basses ?');
116
+    $this->playlists['bux_2_priv'] = $this->findOneBy('Playlist', 'Ma playlist perso');
117
+    $this->playlists['bob_pub'] = $this->findOneBy('Playlist', 'A travers l\'espace');
118
+  }
119
+  
120
+  protected function checkReadablePlaylistsForAnonymous()
121
+  {
122
+    $this->checkReadPlaylists($this->users['bux'], array($this->playlists['bux_1_pub']));
123
+  }
124
+  
125
+  protected function checkReadPlaylists($user, $playlists)
126
+  {
127
+    $this->tests_cases->playlistsShow($user->getSlug());
128
+    $this->isResponseSuccess();
129
+    $this->checkReadPlaylistsDom($playlists);
130
+    
131
+    foreach ($playlists as $playlist)
132
+    {
133
+      $this->tests_cases->playlistShow($user->getSlug(), $playlist->getId());
134
+      $this->isResponseSuccess();
135
+      $this->checkReadPlaylist($playlist);
136
+    }
137
+  }
138
+  
139
+  protected function checkReadPlaylistsDom($playlists)
140
+  {
141
+    $this->outputDebug();
142
+    $this->assertEquals(count($playlists), $this->crawler->filter('ul.playlists li.playlist')->count());
143
+    foreach ($playlists as $playlist)
144
+    {
145
+      $this->exist('a[href="'.$this->generateUrl('playlist_datas_for_autoplay', array('playlist_id' => $playlist->getId())).'"]');
146
+    }
147
+  }
148
+  
149
+  protected function checkReadPlaylist($playlist)
150
+  {
151
+    $this->exist('h2:contains("'.$playlist->getName().'")');
152
+  }
153
+  
154
+  protected function checkReadablePlaylistsForConnected()
155
+  {
156
+    $this->connectUser('jean', 'toor');
157
+    $this->checkReadPlaylists($this->users['bux'], array($this->playlists['bux_1_pub']));
158
+    $this->disconnectUser();
159
+  }
160
+  
161
+  protected function checkReadablePlaylistsForOwner()
162
+  {
163
+    $this->connectUser('bux', 'toor');
164
+    $this->checkReadPlaylists($this->users['bux'], array(
165
+      $this->playlists['bux_1_pub'],
166
+      $this->playlists['bux_2_priv'],
167
+      $this->playlists['bob_pub'],
168
+    ));
169
+  }
170
+  
171
+  public function testPlaylistCreation()
172
+  {
173
+    $this->init();
174
+    $this->initCreateContextData();
175
+    $this->connectUser('joelle', 'toor');
176
+    
177
+    $this->playlists['joelle_1'] = $this->createPlaylistWithElement($this->elements['babylon']);
178
+    $this->checkReadPlaylists($this->users['joelle'], array($this->playlists['joelle_1']));
179
+  }
180
+  
181
+  protected function initCreateContextData()
182
+  {
183
+    $this->initReadContextData();
184
+    $this->users['joelle'] = $this->findUserByUsername('joelle');
185
+    $this->users['bob'] = $this->findUserByUsername('bob');
186
+    $this->elements['babylon'] = $this->findOneBy('Element', 'Babylon Pression - Des Tasers et des Pauvres');
187
+  }
188
+  
189
+  protected function createPlaylistWithElement($element)
190
+  {
191
+    $this->tests_cases->playlistCreate($element->getId(), 'Playlist de test');
192
+    $this->assertTrue(!is_null($playlist = $this->findOneBy('Playlist', 'Playlist de test')));
193
+    return $playlist;
194
+  }
195
+  
196
+}

+ 33 - 0
src/Muzich/CoreBundle/Tests/lib/Security/Context.php 查看文件

@@ -78,6 +78,39 @@ class Context
78 78
       case SecurityContext::ACTION_GET_FAVORITES_TAGS:
79 79
         return $this->security_context_tests->getFavoritesTagsResponseIs($success, $condition);
80 80
       break;
81
+      case SecurityContext::ACTION_PLAYLIST_ADD_ELEMENT:
82
+        return $this->security_context_tests->playlistAddElementResponseIs($success, $condition);
83
+      break;
84
+      case SecurityContext::ACTION_PLAYLIST_UPDATE_ORDER:
85
+        return $this->security_context_tests->playlistUpdateOrderResponseIs($success, $condition);
86
+      break;
87
+      case SecurityContext::ACTION_PLAYLIST_REMOVE_ELEMENT:
88
+        return $this->security_context_tests->playlistRemoveElementResponseIs($success, $condition);
89
+      break;
90
+      case SecurityContext::ACTION_PLAYLIST_CREATE:
91
+        return $this->security_context_tests->playlistCreateResponseIs($success, $condition);
92
+      break;
93
+      case SecurityContext::ACTION_PLAYLIST_COPY:
94
+        return $this->security_context_tests->playlistCopyResponseIs($success, $condition);
95
+      break;
96
+      case SecurityContext::ACTION_PLAYLIST_DELETE:
97
+        return $this->security_context_tests->playlistDeleteResponseIs($success, $condition);
98
+      break;
99
+      case SecurityContext::ACTION_PLAYLIST_UNPICK:
100
+        return $this->security_context_tests->playlistUnpickResponseIs($success, $condition);
101
+      break;
102
+      case SecurityContext::ACTION_PLAYLIST_PICK:
103
+        return $this->security_context_tests->playlistPickResponseIs($success, $condition);
104
+      break;
105
+      case SecurityContext::ACTION_PLAYLIST_SHOW:
106
+        return $this->security_context_tests->playlistShowResponseIs($success, $condition);
107
+      break;
108
+      case SecurityContext::ACTION_PLAYLIST_DATA_AUTOPLAY:
109
+        return $this->security_context_tests->playlistAutoplayResponseIs($success, $condition);
110
+      break;
111
+      case SecurityContext::ACTION_PLAYLIST_ADD_PROMPT:
112
+        return $this->security_context_tests->playlistPromptResponseIs($success, $condition);
113
+      break;
81 114
       default:
82 115
         throw new \Exception('Action unknow');
83 116
     }

+ 253 - 26
src/Muzich/CoreBundle/Tests/lib/Security/ContextTestCases.php 查看文件

@@ -5,6 +5,7 @@ namespace Muzich\CoreBundle\Tests\lib\Security;
5 5
 use Muzich\CoreBundle\lib\Test\Client;
6 6
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
7 7
 use Muzich\CoreBundle\Security\Context as SecurityContext;
8
+use Symfony\Component\DomCrawler\Crawler;
8 9
 
9 10
 class ContextTestCases
10 11
 {
@@ -18,7 +19,7 @@ class ContextTestCases
18 19
     $this->test = $test;
19 20
   }
20 21
   
21
-  private function responseSatisfyConditions($response, $success, $condition)
22
+  private function ajaxResponseSatisfyConditions($response, $success, $condition)
22 23
   {
23 24
     $response = json_decode($response, true);
24 25
     
@@ -45,6 +46,25 @@ class ContextTestCases
45 46
     return false;
46 47
   }
47 48
   
49
+  private function responseSatisfyConditions($response, $success, $condition, $user)
50
+  {
51
+    if (($response->getStatusCode() == 200 || $response->getStatusCode() == 302) && $success)
52
+    {
53
+      return true;
54
+    }
55
+    
56
+    if (($response->getStatusCode() != 302 && $response->getStatusCode() != 302) && !$success)
57
+    {
58
+      $security_context = new SecurityContext($user);
59
+      if ($condition && !$security_context->userIsInThisCondition($condition))
60
+      {
61
+        return false;
62
+      }
63
+      
64
+      return true;
65
+    }
66
+  }
67
+  
48 68
   public function getAjaxRequestContentResponse($method, $url, $parameters = array())
49 69
   {
50 70
     $this->test->getClient()->request(
@@ -56,7 +76,7 @@ class ContextTestCases
56 76
   
57 77
   public function addElementResponseIs($success, $condition)
58 78
   {
59
-    return $this->responseSatisfyConditions(
79
+    return $this->ajaxResponseSatisfyConditions(
60 80
       $this->getAjaxRequestContentResponse(
61 81
         'POST',
62 82
         $this->test->generateUrl('element_add', array('_locale' => 'fr'))
@@ -68,7 +88,7 @@ class ContextTestCases
68 88
   
69 89
   public function noteElementResponseIs($success, $condition)
70 90
   {
71
-    return $this->responseSatisfyConditions(
91
+    return $this->ajaxResponseSatisfyConditions(
72 92
       $this->getAjaxRequestContentResponse(
73 93
         'GET',
74 94
         $this->test->generateUrl('ajax_element_add_vote_good', array(
@@ -83,7 +103,7 @@ class ContextTestCases
83 103
   
84 104
   public function alertCommentResponseIs($success, $condition)
85 105
   {
86
-    return $this->responseSatisfyConditions(
106
+    return $this->ajaxResponseSatisfyConditions(
87 107
       $this->getAjaxRequestContentResponse(
88 108
         'GET',
89 109
         $this->test->generateUrl('ajax_alert_comment', array(
@@ -99,7 +119,7 @@ class ContextTestCases
99 119
   
100 120
   public function alertElementResponseIs($success, $condition)
101 121
   {
102
-    return $this->responseSatisfyConditions(
122
+    return $this->ajaxResponseSatisfyConditions(
103 123
       $this->getAjaxRequestContentResponse(
104 124
         'GET',
105 125
         $this->test->generateUrl('ajax_report_element', array(
@@ -114,7 +134,7 @@ class ContextTestCases
114 134
   
115 135
   public function addTagResponseIs($success, $condition)
116 136
   {
117
-    return $this->responseSatisfyConditions(
137
+    return $this->ajaxResponseSatisfyConditions(
118 138
       $this->getAjaxRequestContentResponse(
119 139
         'POST',
120 140
         $this->test->generateUrl('ajax_add_tag'),
@@ -127,7 +147,7 @@ class ContextTestCases
127 147
   
128 148
   public function proposeElementTagsResponseIs($success, $condition)
129 149
   {
130
-    return $this->responseSatisfyConditions(
150
+    return $this->ajaxResponseSatisfyConditions(
131 151
       $this->getAjaxRequestContentResponse(
132 152
         'POST',
133 153
         $this->test->generateUrl('ajax_element_propose_tags_proceed', 
@@ -161,26 +181,17 @@ class ContextTestCases
161 181
       array()
162 182
     );
163 183
     
164
-    if ($this->test->getClient()->getResponse()->getStatusCode() == 200 && $success)
165
-    {
166
-      return true;
167
-    }
168
-    
169
-    if ($this->test->getClient()->getResponse()->getStatusCode() != 200 && !$success)
170
-    {
171
-      $security_context = new SecurityContext($this->test->getUser());
172
-      if ($condition && !$security_context->userIsInThisCondition($condition))
173
-      {
174
-        return false;
175
-      }
176
-      
177
-      return true;
178
-    }
184
+    return $this->responseSatisfyConditions(
185
+      $this->test->getClient()->getResponse(), 
186
+      $success, 
187
+      $condition, 
188
+      $this->test->getUser()
189
+    );
179 190
   }
180 191
   
181 192
   public function addCommentResponseIs($success, $condition)
182 193
   {
183
-    return $this->responseSatisfyConditions(
194
+    return $this->ajaxResponseSatisfyConditions(
184 195
       $this->getAjaxRequestContentResponse(
185 196
         'POST',
186 197
         $this->test->generateUrl('ajax_add_comment', array(
@@ -195,7 +206,7 @@ class ContextTestCases
195 206
   
196 207
   public function addElementToFavoriteResponseIs($success, $condition)
197 208
   {
198
-    return $this->responseSatisfyConditions(
209
+    return $this->ajaxResponseSatisfyConditions(
199 210
       $this->getAjaxRequestContentResponse(
200 211
         'GET',
201 212
         $this->test->generateUrl('favorite_add', array(
@@ -210,7 +221,7 @@ class ContextTestCases
210 221
   
211 222
   public function followUserResponseIs($success, $condition)
212 223
   {
213
-    return $this->responseSatisfyConditions(
224
+    return $this->ajaxResponseSatisfyConditions(
214 225
       $this->getAjaxRequestContentResponse(
215 226
         'GET',
216 227
         $this->test->generateUrl('follow', array(
@@ -226,7 +237,7 @@ class ContextTestCases
226 237
   
227 238
   public function getFavoritesTagsResponseIs($success, $condition)
228 239
   {
229
-    return $this->responseSatisfyConditions(
240
+    return $this->ajaxResponseSatisfyConditions(
230 241
       $this->getAjaxRequestContentResponse(
231 242
         'GET',
232 243
         $this->test->generateUrl('ajax_get_favorites_tags', array(
@@ -238,4 +249,220 @@ class ContextTestCases
238 249
     );
239 250
   }
240 251
   
252
+  public function playlistAddElementResponseIs($success, $condition)
253
+  {
254
+    return $this->ajaxResponseSatisfyConditions(
255
+      $this->getAjaxRequestContentResponse(
256
+        'GET',
257
+        $this->test->generateUrl('playlists_add_element', array(
258
+          'playlist_id' => 0,
259
+          'element_id'  => 0,
260
+          '_locale'     => 'fr'
261
+        ))
262
+      ), 
263
+      $success, 
264
+      $condition
265
+    );
266
+  }
267
+  
268
+  public function playlistUpdateOrderResponseIs($success, $condition)
269
+  {
270
+    return $this->ajaxResponseSatisfyConditions(
271
+      $this->getAjaxRequestContentResponse(
272
+        'GET',
273
+        $this->test->generateUrl('playlist_update_order', array(
274
+          'playlist_id' => 0,
275
+          '_locale'     => 'fr'
276
+        ))
277
+      ), 
278
+      $success, 
279
+      $condition
280
+    );
281
+  }
282
+  
283
+  public function playlistRemoveElementResponseIs($success, $condition)
284
+  {
285
+    return $this->ajaxResponseSatisfyConditions(
286
+      $this->getAjaxRequestContentResponse(
287
+        'GET',
288
+        $this->test->generateUrl('playlist_remove_element', array(
289
+          'playlist_id' => 0,
290
+          'element_id'  => 0,
291
+          '_locale'     => 'fr'
292
+        ))
293
+      ), 
294
+      $success, 
295
+      $condition
296
+    );
297
+  }
298
+  
299
+  public function playlistCreateResponseIs($success, $condition)
300
+  {
301
+    $this->playlistCreate(0, 'my_super_playlist');
302
+    return $this->ajaxResponseSatisfyConditions(
303
+      $this->test->getClient()->getResponse()->getContent(),
304
+      $success, 
305
+      $condition
306
+    );
307
+  }
308
+  
309
+  public function playlistCreate($element_id, $playlist_name)
310
+  {
311
+    $this->test->goToPage($this->test->generateUrl('playlists_add_element_prompt', array(
312
+      'element_id'  => $element_id,
313
+      '_locale'     => 'fr'
314
+    )));
315
+    
316
+    $response = json_decode($this->test->client->getResponse()->getContent(), true);
317
+    $crawler = new Crawler($response['data']);
318
+    
319
+    $extract = $crawler->filter('input[name="playlist[_token]"]')
320
+      ->extract(array('value'));
321
+    $csrf = $extract[0];
322
+    
323
+    $this->test->crawler = $this->test->client->request(
324
+      'POST', 
325
+      $this->test->generateUrl('playlist_add_element_and_create', array(
326
+        'element_id'  => $element_id,
327
+        '_locale'     => 'fr'
328
+      )), 
329
+      array(
330
+        'playlist' => array(
331
+          'name'   => $playlist_name,
332
+          '_token' => $csrf
333
+        )
334
+      ),
335
+      array(), 
336
+      array('HTTP_X-Requested-With' => 'XMLHttpRequest')
337
+    );
338
+  }
339
+
340
+
341
+  public function playlistCopyResponseIs($success, $condition)
342
+  {
343
+    return $this->ajaxResponseSatisfyConditions(
344
+      $this->getAjaxRequestContentResponse(
345
+        'GET',
346
+        $this->test->generateUrl('playlists_add_element_and_copy', array(
347
+          'playlist_id' => 0,
348
+          'element_id'  => 0,
349
+          '_locale'     => 'fr'
350
+        ))
351
+      ), 
352
+      $success, 
353
+      $condition
354
+    );
355
+  }
356
+  
357
+  public function playlistDeleteResponseIs($success, $condition)
358
+  {
359
+    $this->test->getClient()->request(
360
+      'GET', 
361
+      $this->test->generateUrl('playlist_delete', array(
362
+          'playlist_id' => 0,
363
+          'element_id'  => 0,
364
+          '_locale'     => 'fr'
365
+        )), 
366
+      array(), 
367
+      array(), 
368
+      array()
369
+    );
370
+    
371
+    return $this->responseSatisfyConditions(
372
+      $this->test->getClient()->getResponse(), 
373
+      $success, 
374
+      $condition, 
375
+      $this->test->getUser()
376
+    );
377
+  }
378
+  
379
+  public function playlistUnpickResponseIs($success, $condition)
380
+  {
381
+    return $this->ajaxResponseSatisfyConditions(
382
+      $this->getAjaxRequestContentResponse(
383
+        'GET',
384
+        $this->test->generateUrl('playlist_unpick', array(
385
+          'playlist_id' => 0,
386
+          '_locale'     => 'fr'
387
+        ))
388
+      ), 
389
+      $success, 
390
+      $condition
391
+    );
392
+  }
393
+  
394
+  public function playlistPickResponseIs($success, $condition)
395
+  {
396
+    return $this->ajaxResponseSatisfyConditions(
397
+      $this->getAjaxRequestContentResponse(
398
+        'GET',
399
+        $this->test->generateUrl('playlist_pick', array(
400
+          'playlist_id' => 0,
401
+          '_locale'     => 'fr'
402
+        ))
403
+      ), 
404
+      $success, 
405
+      $condition
406
+    );
407
+  }
408
+  
409
+  public function playlistShowResponseIs($success, $condition)
410
+  {
411
+    $this->playlistShow('bux', 0);
412
+    
413
+    return $this->responseSatisfyConditions(
414
+      $this->test->getClient()->getResponse(), 
415
+      $success, 
416
+      $condition, 
417
+      $this->test->getUser()
418
+    );
419
+  }
420
+  
421
+  public function playlistsShow($user_slug)
422
+  {
423
+    $this->test->goToPage($this->test->generateUrl('playlists_user', array(
424
+      'user_slug'   => $user_slug,
425
+      '_locale'     => 'fr'
426
+    )));
427
+  }
428
+  
429
+  public function playlistShow($user_slug, $playlist_id)
430
+  {
431
+    $this->test->goToPage($this->test->generateUrl('playlist', array(
432
+      'user_slug'   => $user_slug,
433
+      'playlist_id' => $playlist_id,
434
+      '_locale'     => 'fr'
435
+    )));
436
+  }
437
+  
438
+  public function playlistAutoplayResponseIs($success, $condition)
439
+  {
440
+    return $this->ajaxResponseSatisfyConditions(
441
+      $this->getAjaxRequestContentResponse(
442
+        'GET',
443
+        $this->test->generateUrl('playlist_datas_for_autoplay', array(
444
+          'playlist_id' => 0,
445
+          '_locale'     => 'fr'
446
+        ))
447
+      ), 
448
+      $success, 
449
+      $condition
450
+    );
451
+  }
452
+  
453
+  public function playlistPromptResponseIs($success, $condition)
454
+  {
455
+    return $this->ajaxResponseSatisfyConditions(
456
+      $this->getAjaxRequestContentResponse(
457
+        'GET',
458
+        $this->test->generateUrl('playlists_add_element_prompt', array(
459
+          'element_id' => 0,
460
+          '_locale'    => 'fr'
461
+        ))
462
+      ), 
463
+      $success, 
464
+      $condition
465
+    );
466
+  }
467
+  
241 468
 }

+ 4 - 4
src/Muzich/CoreBundle/lib/FunctionalTest.php 查看文件

@@ -16,13 +16,13 @@ class FunctionalTest extends WebTestCase
16 16
    *
17 17
    * @var Client 
18 18
    */
19
-  protected $client;
19
+  public $client;
20 20
   
21 21
   /**
22 22
    *
23 23
    * @var Crawler 
24 24
    */
25
-  protected $crawler;
25
+  public $crawler;
26 26
   
27 27
   public function getClient()
28 28
   {
@@ -34,7 +34,7 @@ class FunctionalTest extends WebTestCase
34 34
     return $this->crawler;
35 35
   }
36 36
   
37
-  protected function outputDebug($content = null)
37
+  public function outputDebug($content = null)
38 38
   {
39 39
     $time = time();
40 40
     //unlink('.debug/out'.$time.'.html');
@@ -353,7 +353,7 @@ class FunctionalTest extends WebTestCase
353 353
   {
354 354
     $this->assertTrue($this->crawler->filter($filter)->count() > 0);
355 355
   }
356
-  
356
+    
357 357
   /**
358 358
    * Test l'inexistance d'un element
359 359
    * 

+ 1 - 1
src/Muzich/PlaylistBundle/Controller/EditController.php 查看文件

@@ -100,7 +100,7 @@ class EditController extends Controller
100 100
   public function deleteAction($playlist_id)
101 101
   {
102 102
     if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_DELETE)) !== false)
103
-      return $this->jsonResponseError($uncondition);
103
+      throw $this->createNotFoundException();
104 104
     
105 105
     if (!($playlist = $this->getPlaylistManager()->findOwnedPlaylistWithId($playlist_id, $this->getUser())))
106 106
       throw $this->createNotFoundException();

+ 1 - 1
src/Muzich/PlaylistBundle/Resources/views/Show/user.html.twig 查看文件

@@ -8,7 +8,7 @@
8 8
   {% if playlists|length %}
9 9
   <ul class="playlists">
10 10
     {% for playlist in playlists %}
11
-      <li>
11
+      <li class="playlist">
12 12
         
13 13
         <a class="autoplay_playlist" href="{{ path('playlist_datas_for_autoplay', { 'playlist_id' : playlist.id }) }}" >
14 14
           Lire