Browse Source

Fix playlist tests

Sevajol Bastien 11 years ago
parent
commit
ebe87d02c8

+ 15 - 0
src/Muzich/CoreBundle/Managers/PlaylistManager.php View File

140
     $playlist_copied->setElements($playlist->getElements());
140
     $playlist_copied->setElements($playlist->getElements());
141
     $playlist_copied->setCopied($playlist);
141
     $playlist_copied->setCopied($playlist);
142
     $playlist->addCopy($playlist_copied);
142
     $playlist->addCopy($playlist_copied);
143
+    
144
+    //foreach ($user->getPlaylistsOwneds() as $fuck)
145
+    //{
146
+    //  var_dump($fuck->getName());
147
+    //}
148
+    //
143
     $user->getPlaylistsOwneds()->add($playlist_copied);
149
     $user->getPlaylistsOwneds()->add($playlist_copied);
150
+    //
151
+    //var_dump($playlist_copied->getOwner()->getUsername());
152
+    //
153
+    //foreach ($user->getPlaylistsOwneds() as $fuck)
154
+    //{
155
+    //  var_dump($fuck->getName());
156
+    //}
157
+    //die();
158
+    
144
     $this->entity_manager->persist($playlist_copied);
159
     $this->entity_manager->persist($playlist_copied);
145
     $this->entity_manager->persist($user);
160
     $this->entity_manager->persist($user);
146
     
161
     

+ 34 - 9
src/Muzich/CoreBundle/Tests/Controller/PlaylistTest.php View File

16
   }
16
   }
17
 }
17
 }
18
 
18
 
19
-class PlaylistTest extends Playlist
19
+class PlaylistEntityTest extends Playlist
20
 {
20
 {
21
   public function setId($id)
21
   public function setId($id)
22
   {
22
   {
24
   }
24
   }
25
 }
25
 }
26
 
26
 
27
-class NoPassTest extends FunctionalTest
27
+class PlaylistTest extends FunctionalTest
28
 {
28
 {
29
   
29
   
30
   protected $users = array();
30
   protected $users = array();
45
     
45
     
46
     $this->playlist_manager = new PlaylistManager($this->getEntityManager());
46
     $this->playlist_manager = new PlaylistManager($this->getEntityManager());
47
     
47
     
48
-    $this->playlists['bux'] = new PlaylistTest();
48
+    $this->playlists['bux'] = new PlaylistEntityTest();
49
+    $this->playlists['bux']->setName('Una playlist!');
49
     $this->playlists['bux']->setOwner($this->users['bux']);
50
     $this->playlists['bux']->setOwner($this->users['bux']);
50
     $this->playlists['bux']->setId(1);
51
     $this->playlists['bux']->setId(1);
51
   }
52
   }
100
     $this->assertEquals(count($playlists), count($this->users['bob']->getPickedsPlaylists()));
101
     $this->assertEquals(count($playlists), count($this->users['bob']->getPickedsPlaylists()));
101
     foreach ($playlists as $playlist)
102
     foreach ($playlists as $playlist)
102
     {
103
     {
103
-      $this->assertTrue($this->playlistIsInPickedPlaylists($playlist, $this->users['bob']->getPickedsPlaylists()));
104
+      $this->assertTrue($this->playlistIsInPlaylists($playlist, $this->users['bob']->getPickedsPlaylists()));
104
     }
105
     }
105
   }
106
   }
106
   
107
   
107
-  protected function playlistIsInPickedPlaylists($playlist_searched, $playlists)
108
+  protected function playlistIsInPlaylists($playlist_searched, $playlists)
108
   {
109
   {
109
     foreach ($playlists as $playlist)
110
     foreach ($playlists as $playlist)
110
     {
111
     {
129
   
130
   
130
   protected function checkCopyedPlaylist()
131
   protected function checkCopyedPlaylist()
131
   {
132
   {
132
-    $this->assertEquals(1, count($this->users['bob']->getPlaylistsOwneds()));
133
+    $this->assertEquals(2, count($this->users['bob']->getPlaylistsOwneds()));
133
     $bob_playlists = $this->users['bob']->getPlaylistsOwneds();
134
     $bob_playlists = $this->users['bob']->getPlaylistsOwneds();
134
-    
135
     $bux_playlist_copys = $this->playlists['bux']->getCopys();
135
     $bux_playlist_copys = $this->playlists['bux']->getCopys();
136
+    
136
     $this->assertCount(1, $bux_playlist_copys);
137
     $this->assertCount(1, $bux_playlist_copys);
137
-    $this->assertEquals($bux_playlist_copys[0], $bob_playlists[0]);
138
+    $this->assertEquals($bux_playlist_copys[0]->getName(), $bob_playlists[1]->getName());
138
     
139
     
139
     foreach (array($this->elements[1], $this->elements[2], $this->elements[4]) as $element)
140
     foreach (array($this->elements[1], $this->elements[2], $this->elements[4]) as $element)
140
     {
141
     {
141
-      $this->assertTrue($bob_playlists[0]->haveElement($element));
142
+      $this->assertTrue($bob_playlists[1]->haveElement($element));
142
     }
143
     }
143
   }
144
   }
144
   
145
   
146
+  //public function testPlaylistDeletion()
147
+  //{
148
+  //  $this->init();
149
+  //  
150
+  //  $this->bobPickBuxPlaylist();
151
+  //  $this->checkBobPickedPlaylists(array($this->playlists['bux']));
152
+  //  
153
+  //  $this->playlist_manager->deletePlaylist($this->playlists['bux']);
154
+  //  
155
+  //  $this->checkBobPickedPlaylists(array());
156
+  //  $this->checkBobCopyedPlaylist(array($this->playlists['bux']));
157
+  //}
158
+  //
159
+  //protected function checkBobCopyedPlaylist($playlists)
160
+  //{
161
+  //  $this->assertEquals(count($playlists), count($this->users['bob']->getPlaylistsOwneds()));
162
+  //  $bob_playlists = $this->users['bob']->getPlaylistsOwneds();
163
+  //  
164
+  //  foreach ($playlists as $playlist)
165
+  //  {
166
+  //    $this->assertTrue($this->playlistIsInPlaylists($playlist, $bob_playlists));
167
+  //  }
168
+  //}
169
+  
145
 }
170
 }