Browse Source

test fix: probleme de persist et suppression d'éléments ajouté lors des tests unitaires.

bastien 13 years ago
parent
commit
0a6f4d6193

+ 1 - 1
src/Muzich/CoreBundle/Tests/Tag/TagReadTest.php View File

@@ -148,7 +148,7 @@ class TagReadTest extends UnitTest
148 148
     $paul = $this->getUser('paul');
149 149
     
150 150
     ////////////////////////////////
151
-    $rtags = array('Electro', 'Hardcore', 'Hardtek', 'Metal', 'Tribe');
151
+    $rtags = array('Electro', 'Hardcore', 'Hardtek', 'Metal');
152 152
     
153 153
     $tags = $this->getTagsNamesForQuery($this->getDoctrine()->getRepository('MuzichCoreBundle:User')
154 154
       ->getElementsTags($bux->getId())      

+ 24 - 0
src/Muzich/CoreBundle/Tests/Tag/TagWriteTest.php View File

@@ -17,6 +17,7 @@ class TagWriteTest extends UnitTest
17 17
   
18 18
   public function testAddTag()
19 19
   {
20
+    $this->clean();
20 21
     $bux = $this->getUser('bux');
21 22
     $paul = $this->getUser('paul');
22 23
     
@@ -76,10 +77,12 @@ class TagWriteTest extends UnitTest
76 77
       ))
77 78
     ;
78 79
     $this->assertTrue(!is_null($tag_database));
80
+    $this->clean();
79 81
   }
80 82
   
81 83
   public function testModerateTag()
82 84
   {
85
+    $this->clean();
83 86
     $bux = $this->getUser('bux');
84 87
     
85 88
     // Ajout de tags
@@ -308,6 +311,27 @@ class TagWriteTest extends UnitTest
308 311
       ))
309 312
     ;
310 313
     $this->assertTrue(!is_null($fav));
314
+    
315
+    $this->getDoctrine()->getEntityManager()->persist($tag_3);
316
+    $this->clean();
317
+  }
318
+  
319
+  protected function clean()
320
+  {
321
+    $tag1 = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
322
+      ->findOneByName('Nouveau 1');
323
+    $tag2 = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
324
+      ->findOneByName('Nouveau 2');
325
+    $tag3 = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
326
+      ->findOneByName('Nouveau 3');
327
+    $tag4 = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
328
+      ->findOneByName('Xvlsd aoj 12');
329
+    
330
+    ($tag1) ? $this->getDoctrine()->getEntityManager()->remove($tag1) : '';
331
+    ($tag2) ? $this->getDoctrine()->getEntityManager()->remove($tag2) : '';
332
+    ($tag3) ? $this->getDoctrine()->getEntityManager()->remove($tag3) : '';
333
+    ($tag4) ? $this->getDoctrine()->getEntityManager()->remove($tag4) : '';
334
+    $this->getDoctrine()->getEntityManager()->flush();
311 335
   }
312 336
   
313 337
 }