Browse Source

fix ApiResponse for tests

Bastien Sevajol 11 years ago
parent
commit
b8914ac865

+ 2 - 2
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php View File

@@ -263,7 +263,7 @@ class ElementFactoryTest extends UnitTest
263 263
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
264 264
         .'&width='.$this->getParam('deezer_player_width').'&height='
265 265
         .$this->getParam('deezer_player_height')
266
-        .'&cover=true&btn_popup=true&type=album&id=80398&title=" '
266
+        .'&cover=true&type=album&id=80398&title=&app_id=undefined" '
267 267
         .'width="'.$this->getParam('deezer_player_width').'" height="'
268 268
         .$this->getParam('deezer_player_height')
269 269
         .'"></iframe>'
@@ -278,7 +278,7 @@ class ElementFactoryTest extends UnitTest
278 278
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
279 279
         .'&width='.$this->getParam('deezer_player_width').'&height='
280 280
         .$this->getParam('deezer_player_height')
281
-        .'&cover=true&btn_popup=true&type=playlist&id=18701350&title=" '
281
+        .'&cover=true&type=playlist&id=18701350&title=&app_id=undefined" '
282 282
         .'width="'.$this->getParam('deezer_player_width').'" height="'
283 283
         .$this->getParam('deezer_player_height')
284 284
         .'"></iframe>'

+ 16 - 13
src/Muzich/CoreBundle/lib/Api/Response.php View File

@@ -7,7 +7,7 @@ class Response
7 7
   
8 8
   protected $content = array();
9 9
   
10
-  public function __construct($content)
10
+  public function __construct($content = array())
11 11
   {
12 12
     $this->content = $content;
13 13
   }
@@ -17,9 +17,9 @@ class Response
17 17
     return !$this->have($searched);
18 18
   }
19 19
   
20
-  public function have($searched, $not_empty = true, $content = null)
20
+  public function have($searched, $not_empty = true, $content = array())
21 21
   {
22
-    if (!$content)
22
+    if (!$content || !count($content))
23 23
       $content = $this->content;
24 24
     
25 25
     if (is_array($searched))
@@ -30,24 +30,27 @@ class Response
30 30
       }
31 31
     }
32 32
     
33
-    if (array_key_exists($searched, $content))
33
+    if ($content)
34 34
     {
35
-      if ($not_empty)
35
+      if (array_key_exists($searched, $content))
36 36
       {
37
-        if ((is_null($content[$searched]) || !count($content[$searched]) || !$content[$searched]) && ($content[$searched] !== 0 && $content[$searched] !== '0'))
38
-        {
39
-          return false;
40
-        }
41
-        if (is_string($content[$searched]))
37
+        if ($not_empty)
42 38
         {
43
-          if (trim($content[$searched]) == '')
39
+          if ((is_null($content[$searched]) || !count($content[$searched]) || !$content[$searched]) && ($content[$searched] !== 0 && $content[$searched] !== '0'))
44 40
           {
45 41
             return false;
46 42
           }
43
+          if (is_string($content[$searched]))
44
+          {
45
+            if (trim($content[$searched]) == '')
46
+            {
47
+              return false;
48
+            }
49
+          }
47 50
         }
51
+
52
+        return true;
48 53
       }
49
-      
50
-      return true;
51 54
     }
52 55
     
53 56
     return false;