瀏覽代碼

blcklist pour le code coverage + Correction d'un bout de code qui se comporte mal en test

bastien 12 年之前
父節點
當前提交
425ea39cde

+ 21 - 3
app/phpunit.xml.dist 查看文件

27
     
27
     
28
     <filter>
28
     <filter>
29
       <blacklist>
29
       <blacklist>
30
+        
31
+        
32
+
33
+
34
+
30
         <directory suffix=".php">../src/Acme</directory>
35
         <directory suffix=".php">../src/Acme</directory>
31
-        <exclude>
32
-          <directory suffix=".php">../src/Acme/DemoBundle</directory>
33
-        </exclude>
36
+        
34
       </blacklist>
37
       </blacklist>
35
 
38
 
36
       <whitelist addUncoveredFilesFromWhitelist="true">
39
       <whitelist addUncoveredFilesFromWhitelist="true">
37
         <directory suffix=".php">../src/Muzich</directory>
40
         <directory suffix=".php">../src/Muzich</directory>
41
+        <exclude>
42
+          <directory suffix=".php">../src/Muzich/CoreBundle/DataFixtures</directory>
43
+
44
+          <directory suffix=".php">../src/Muzich/FavoriteBundle/DependencyInjection</directory>
45
+
46
+          <directory suffix=".php">../src/Muzich/GroupBundle/DependencyInjection</directory>
47
+          <directory suffix=".php">../src/Muzich/GroupBundle/Tests</directory>
48
+
49
+          <directory suffix=".php">../src/Muzich/MynetworkBundle/DependencyInjection</directory>
50
+
51
+          <directory suffix=".php">../src/Muzich/UserBundle/DataFixtures</directory>
52
+          <directory suffix=".php">../src/Muzich/UserBundle/DependencyInjection</directory>
53
+          <directory suffix=".php">../src/Muzich/UserBundle/Tests</directory>
54
+          <directory suffix=".php">../src/Muzich/UserBundle/Entity</directory>
55
+        </exclude>
38
       </whitelist>
56
       </whitelist>
39
     </filter>
57
     </filter>
40
 
58
 

+ 1 - 1
src/Muzich/CoreBundle/Tests/Controller/FavoriteControllerTest.php 查看文件

115
     ))).'"]');
115
     ))).'"]');
116
     $link = $this->selectLink('a[href="'.$url.'"]');
116
     $link = $this->selectLink('a[href="'.$url.'"]');
117
     $this->clickOnLink($link);
117
     $this->clickOnLink($link);
118
-    $this->outputDebug();
118
+    
119
     $this->isResponseRedirection();
119
     $this->isResponseRedirection();
120
     $this->followRedirection();
120
     $this->followRedirection();
121
     $this->isResponseSuccess();
121
     $this->isResponseSuccess();

+ 1 - 1
src/Muzich/CoreBundle/Tests/Controller/MynetworkControllerTest.php 查看文件

57
     $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
57
     $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
58
     $form['form[string]'] = 'bob';
58
     $form['form[string]'] = 'bob';
59
     $this->submit($form);
59
     $this->submit($form);
60
-    $this->outputDebug();
60
+    
61
     $this->isResponseSuccess();
61
     $this->isResponseSuccess();
62
     
62
     
63
     // On trouve bob
63
     // On trouve bob

+ 12 - 0
src/Muzich/UserBundle/Controller/UserController.php 查看文件

133
     $request = $this->getRequest();
133
     $request = $this->getRequest();
134
     $user = $this->getUser(true, array('join' => array('favorites_tags')));
134
     $user = $this->getUser(true, array('join' => array('favorites_tags')));
135
     
135
     
136
+    /**
137
+     * Bug lors des tests: L'user n'est pas 'lié' a celui en base par doctrine.
138
+     * Docrine le voit si on faire une requete directe.
139
+     */
140
+    if ($this->container->getParameter('env') == 'test')
141
+    {
142
+      $user = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')->findOneById(
143
+        $this->container->get('security.context')->getToken()->getUser()->getId(),
144
+        array()
145
+      )->getSingleResult();
146
+    }
147
+    
136
     $form = $this->createForm(
148
     $form = $this->createForm(
137
       new TagFavoritesForm(), 
149
       new TagFavoritesForm(), 
138
       array('tags' => $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
150
       array('tags' => $this->getDoctrine()->getRepository('MuzichCoreBundle:User')