Browse Source

Evolution #124: Du tessst et encore du test: premiers test dajout de tags

bastien 12 years ago
parent
commit
aed7187e79

+ 1 - 1
src/Muzich/CoreBundle/Managers/TagManager.php View File

@@ -36,7 +36,7 @@ class TagManager
36 36
     $tag->setSlug($this->nameCanonicalizer->canonicalize($tag->getName()));
37 37
   }
38 38
   
39
-  public function addTag(Registry $doctrine, $name, $user, $arguments)
39
+  public function addTag(Registry $doctrine, $name, $user, $arguments = null)
40 40
   {
41 41
     $name_canonicalized = $this->nameCanonicalizer->canonicalize(trim($name));
42 42
     

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

@@ -3,10 +3,77 @@
3 3
 namespace Muzich\CoreBundle\Tests\Searcher;
4 4
 
5 5
 use Muzich\CoreBundle\lib\UnitTest;
6
+use Muzich\CoreBundle\Managers\TagManager;
6 7
 
7 8
 class TagWriteTest extends UnitTest
8 9
 {  
9 10
   
11
+  public function testAddTag()
12
+  {
13
+    $bux = $this->getUser('bux');
14
+    $paul = $this->getUser('paul');
15
+    
16
+    $tagManager = new TagManager();
17
+    $tag_returned = $tagManager->addTag(
18
+      $this->getDoctrine(), 
19
+      'Xvlsd aoj 12', 
20
+      $bux
21
+    );
22
+    
23
+    $this->assertTrue(!is_null($tag_returned));
24
+    
25
+    // Simple ajout de tag en base
26
+    $tag_database = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
27
+      ->findBy(array(
28
+        'name'       => 'Xvlsd aoj 12',
29
+        'tomoderate' => true,
30
+        'privateids' => json_encode(array($bux->getId()))
31
+      ))
32
+    ;
33
+    $this->assertTrue(!is_null($tag_database));
34
+    
35
+    // Si la demande est réitéré (bug js) pas de changements
36
+    $tag_returned = $tagManager->addTag(
37
+      $this->getDoctrine(), 
38
+      'Xvlsd aoj 12', 
39
+      $bux
40
+    );
41
+    
42
+    $this->assertTrue(!is_null($tag_returned));
43
+    
44
+    // Simple ajout de tag en base
45
+    $tag_database = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
46
+      ->findBy(array(
47
+        'name'       => 'Xvlsd aoj 12',
48
+        'tomoderate' => true,
49
+        'privateids' => json_encode(array($bux->getId()))
50
+      ))
51
+    ;
52
+    $this->assertTrue(!is_null($tag_database));
53
+    
54
+    // Si un autre user fait la demande sur ce même nom
55
+    $tag_returned = $tagManager->addTag(
56
+      $this->getDoctrine(), 
57
+      'Xvlsd aoj 12', 
58
+      $paul
59
+    );
60
+    
61
+    $this->assertTrue(!is_null($tag_returned));
62
+    
63
+    // Simple ajout de tag en base
64
+    $tag_database = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
65
+      ->findBy(array(
66
+        'name'       => 'Xvlsd aoj 12',
67
+        'tomoderate' => true,
68
+        'privateids' => json_encode(array($bux->getId(), $paul->getId()))
69
+      ))
70
+    ;
71
+    $this->assertTrue(!is_null($tag_database));
72
+  }
10 73
   
74
+  public function testModerateTag()
75
+  {
76
+    
77
+  }
11 78
   
12 79
 }