Преглед на файлове

fix ApiResponse for tests

Bastien Sevajol преди 11 години
родител
ревизия
b8914ac865
променени са 2 файла, в които са добавени 18 реда и са изтрити 15 реда
  1. 2 2
      src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php
  2. 16 13
      src/Muzich/CoreBundle/lib/Api/Response.php

+ 2 - 2
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php Целия файл

263
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
263
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
264
         .'&width='.$this->getParam('deezer_player_width').'&height='
264
         .'&width='.$this->getParam('deezer_player_width').'&height='
265
         .$this->getParam('deezer_player_height')
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
         .'width="'.$this->getParam('deezer_player_width').'" height="'
267
         .'width="'.$this->getParam('deezer_player_width').'" height="'
268
         .$this->getParam('deezer_player_height')
268
         .$this->getParam('deezer_player_height')
269
         .'"></iframe>'
269
         .'"></iframe>'
278
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
278
         .'src="http://www.deezer.com/fr/plugins/player?autoplay=true&playlist=true'
279
         .'&width='.$this->getParam('deezer_player_width').'&height='
279
         .'&width='.$this->getParam('deezer_player_width').'&height='
280
         .$this->getParam('deezer_player_height')
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
         .'width="'.$this->getParam('deezer_player_width').'" height="'
282
         .'width="'.$this->getParam('deezer_player_width').'" height="'
283
         .$this->getParam('deezer_player_height')
283
         .$this->getParam('deezer_player_height')
284
         .'"></iframe>'
284
         .'"></iframe>'

+ 16 - 13
src/Muzich/CoreBundle/lib/Api/Response.php Целия файл

7
   
7
   
8
   protected $content = array();
8
   protected $content = array();
9
   
9
   
10
-  public function __construct($content)
10
+  public function __construct($content = array())
11
   {
11
   {
12
     $this->content = $content;
12
     $this->content = $content;
13
   }
13
   }
17
     return !$this->have($searched);
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
       $content = $this->content;
23
       $content = $this->content;
24
     
24
     
25
     if (is_array($searched))
25
     if (is_array($searched))
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
             return false;
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
     return false;
56
     return false;