Browse Source

test fixs remniement code factorys

Sevajol Bastien 12 years ago
parent
commit
3525f20b68

+ 1 - 1
src/Muzich/CoreBundle/Command/CheckModerateCommand.php View File

8
 use Symfony\Component\Console\Input\InputOption;
8
 use Symfony\Component\Console\Input\InputOption;
9
 use Symfony\Component\Console\Output\OutputInterface;
9
 use Symfony\Component\Console\Output\OutputInterface;
10
 
10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12
 
12
 
13
 class CheckModerateCommand extends ContainerAwareCommand
13
 class CheckModerateCommand extends ContainerAwareCommand
14
 {
14
 {

+ 1 - 1
src/Muzich/CoreBundle/Command/RefreshEmbedsCommand.php View File

8
 use Symfony\Component\Console\Input\InputOption;
8
 use Symfony\Component\Console\Input\InputOption;
9
 use Symfony\Component\Console\Output\OutputInterface;
9
 use Symfony\Component\Console\Output\OutputInterface;
10
 
10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12
 
12
 
13
 class RefreshEmbedsCommand extends ContainerAwareCommand
13
 class RefreshEmbedsCommand extends ContainerAwareCommand
14
 {
14
 {

+ 1 - 1
src/Muzich/CoreBundle/Command/UpdateTagSlugsCommand.php View File

8
 use Symfony\Component\Console\Input\InputOption;
8
 use Symfony\Component\Console\Input\InputOption;
9
 use Symfony\Component\Console\Output\OutputInterface;
9
 use Symfony\Component\Console\Output\OutputInterface;
10
 
10
 
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12
 
12
 
13
 class UpdateTagSlugsCommand extends ContainerAwareCommand
13
 class UpdateTagSlugsCommand extends ContainerAwareCommand
14
 {
14
 {

+ 1 - 1
src/Muzich/CoreBundle/Controller/CoreController.php View File

8
 use Muzich\CoreBundle\Entity\FollowGroup;
8
 use Muzich\CoreBundle\Entity\FollowGroup;
9
 //use Doctrine\ORM\Query;
9
 //use Doctrine\ORM\Query;
10
 use Muzich\CoreBundle\Form\Element\ElementAddForm;
10
 use Muzich\CoreBundle\Form\Element\ElementAddForm;
11
-use Muzich\CoreBundle\ElementFactory\ElementManager;
11
+use Muzich\CoreBundle\Managers\ElementManager;
12
 use Muzich\CoreBundle\Entity\Element;
12
 use Muzich\CoreBundle\Entity\Element;
13
 use Symfony\Component\HttpFoundation\RedirectResponse;
13
 use Symfony\Component\HttpFoundation\RedirectResponse;
14
 use Muzich\CoreBundle\Form\Search\ElementSearchForm;
14
 use Muzich\CoreBundle\Form\Search\ElementSearchForm;

+ 1 - 1
src/Muzich/CoreBundle/Controller/ElementController.php View File

3
 namespace Muzich\CoreBundle\Controller;
3
 namespace Muzich\CoreBundle\Controller;
4
 
4
 
5
 use Muzich\CoreBundle\lib\Controller;
5
 use Muzich\CoreBundle\lib\Controller;
6
-use Muzich\CoreBundle\ElementFactory\ElementManager;
6
+use Muzich\CoreBundle\Managers\ElementManager;
7
 use Muzich\CoreBundle\Propagator\EventElement;
7
 use Muzich\CoreBundle\Propagator\EventElement;
8
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
8
 use Muzich\CoreBundle\Entity\ElementTagsProposition;
9
 
9
 

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Dailymotioncom.php View File

31
     // Récupération de données auprés de l'API
31
     // Récupération de données auprés de l'API
32
     if ($ref_id)
32
     if ($ref_id)
33
     {
33
     {
34
-      $api_url = curl_init('https://api.dailymotion.com/video/'.$chaines[2]
34
+      $api_url = curl_init('https://api.dailymotion.com/video/'.$ref_id
35
         .'&fields=thumbnail_medium_url');
35
         .'&fields=thumbnail_medium_url');
36
       
36
       
37
       $options = array(
37
       $options = array(

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Jamendocom.php View File

96
     {
96
     {
97
       $height = $this->container->getParameter('jamendo_player_height');
97
       $height = $this->container->getParameter('jamendo_player_height');
98
       $width = $this->container->getParameter('jamendo_player_width');
98
       $width = $this->container->getParameter('jamendo_player_width');
99
-      $embed_url = "http://widgets.jamendo.com/fr/$type/?album_id=$ref_id&playertype=2008";
99
+      $embed_url = "http://widgets.jamendo.com/fr/$type/?".$type."_id=$ref_id&playertype=2008";
100
       $this->element->setEmbed(
100
       $this->element->setEmbed(
101
         '<object width="'.$width.'" height="'.$height.'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
101
         '<object width="'.$width.'" height="'.$height.'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
102
             .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
102
             .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">

+ 5 - 4
src/Muzich/CoreBundle/Factory/Elements/Soundcloudcom.php View File

9
  *
9
  *
10
  * @author bux
10
  * @author bux
11
  */
11
  */
12
-class SoundcloudcomFactory extends ElementFactory
12
+class Soundcloudcom extends ElementFactory
13
 {
13
 {
14
   
14
   
15
   /**
15
   /**
24
     // ??SET
24
     // ??SET
25
     if (preg_match("#^\/[a-zA-Z0-9_-]+\/sets\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
25
     if (preg_match("#^\/[a-zA-Z0-9_-]+\/sets\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
26
     {
26
     {
27
-      $ref_id = $url;
27
+      $ref_id = $url_clean;
28
     }
28
     }
29
     // ???
29
     // ???
30
     else if (preg_match("#^\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
30
     else if (preg_match("#^\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+#", $url_clean, $chaines))
31
     {
31
     {
32
-      $ref_id = $url;
32
+      $ref_id = $url_clean;
33
     }
33
     }
34
     
34
     
35
     // On en gère pas encore les recherches
35
     // On en gère pas encore les recherches
43
     // récupération de données avec l'API
43
     // récupération de données avec l'API
44
     if ($ref_id)
44
     if ($ref_id)
45
     {
45
     {
46
-      $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$url_object.'&client_id=39946ea18e3d78d64c0ac95a025794e1');
46
+      $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$ref_id.'&client_id=39946ea18e3d78d64c0ac95a025794e1');
47
 
47
 
48
       $options = array(
48
       $options = array(
49
         CURLOPT_RETURNTRANSFER => true,
49
         CURLOPT_RETURNTRANSFER => true,
77
   {
77
   {
78
     if (($ref_id = $this->element->getData('ref_id')))
78
     if (($ref_id = $this->element->getData('ref_id')))
79
     {
79
     {
80
+      $ref_id = 'http://soundcloud.com'.$ref_id;
80
       $embed_id = md5($ref_id);
81
       $embed_id = md5($ref_id);
81
       $height = $this->container->getParameter('soundcloud_player_height');
82
       $height = $this->container->getParameter('soundcloud_player_height');
82
       $this->element->setEmbed(
83
       $this->element->setEmbed(

+ 1 - 1
src/Muzich/CoreBundle/Factory/Elements/Youtube.php View File

19
     
19
     
20
     if (preg_match("#\/([a-zA-Z0-9]+)#", $url_clean, $chaines))
20
     if (preg_match("#\/([a-zA-Z0-9]+)#", $url_clean, $chaines))
21
     {
21
     {
22
-      $ref_id = $chaines[2];
22
+      $ref_id = $chaines[1];
23
     }
23
     }
24
     
24
     
25
     $this->element->setData('ref_id', $ref_id);
25
     $this->element->setData('ref_id', $ref_id);

+ 12 - 12
src/Muzich/CoreBundle/Managers/ElementManager.php View File

7
 use Doctrine\ORM\EntityManager;
7
 use Doctrine\ORM\EntityManager;
8
 use Symfony\Component\DependencyInjection\Container;
8
 use Symfony\Component\DependencyInjection\Container;
9
 
9
 
10
-use Muzich\CoreBundle\Factory\Elements\YoutubecomFactory;
11
-use Muzich\CoreBundle\Factory\Elements\YoutubeFactory;
12
-use Muzich\CoreBundle\Factory\Elements\DailymotioncomFactory;
13
-use Muzich\CoreBundle\Factory\Elements\JamendocomFactory;
14
-use Muzich\CoreBundle\Factory\Elements\SoundcloudcomFactory;
15
-use Muzich\CoreBundle\Factory\Elements\DeezercomFactory;
10
+use Muzich\CoreBundle\Factory\Elements\Youtubecom;
11
+use Muzich\CoreBundle\Factory\Elements\Youtube;
12
+use Muzich\CoreBundle\Factory\Elements\Dailymotioncom;
13
+use Muzich\CoreBundle\Factory\Elements\Jamendocom;
14
+use Muzich\CoreBundle\Factory\Elements\Soundcloudcom;
15
+use Muzich\CoreBundle\Factory\Elements\Deezercom;
16
 
16
 
17
 /**
17
 /**
18
  * 
18
  * 
147
     switch ($this->element->getType())
147
     switch ($this->element->getType())
148
     {
148
     {
149
       case 'youtube.com':
149
       case 'youtube.com':
150
-        return new YoutubecomFactory($this->element, $this->container);
150
+        return new Youtubecom($this->element, $this->container);
151
       break;
151
       break;
152
       case 'youtu.be':
152
       case 'youtu.be':
153
-        return new YoutubeFactory($this->element, $this->container);
153
+        return new Youtube($this->element, $this->container);
154
       break;
154
       break;
155
       case 'soundcloud.com':
155
       case 'soundcloud.com':
156
-        return new SoundcloudcomFactory($this->element, $this->container);
156
+        return new Soundcloudcom($this->element, $this->container);
157
       break;
157
       break;
158
       case 'jamendo.com':
158
       case 'jamendo.com':
159
-        return new JamendocomFactory($this->element, $this->container);
159
+        return new Jamendocom($this->element, $this->container);
160
       break;
160
       break;
161
       case 'dailymotion.com':
161
       case 'dailymotion.com':
162
-        return new DailymotioncomFactory($this->element, $this->container);
162
+        return new Dailymotioncom($this->element, $this->container);
163
       break;
163
       break;
164
       case 'deezer.com':
164
       case 'deezer.com':
165
-        return new DeezercomFactory($this->element, $this->container);
165
+        return new Deezercom($this->element, $this->container);
166
       break;
166
       break;
167
       default:
167
       default:
168
         throw new \Exception("La Factory n'est pas prise en charge pour ce type.");
168
         throw new \Exception("La Factory n'est pas prise en charge pour ce type.");

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

4
 
4
 
5
 use Muzich\CoreBundle\lib\UnitTest;
5
 use Muzich\CoreBundle\lib\UnitTest;
6
 use Muzich\CoreBundle\Entity\Element;
6
 use Muzich\CoreBundle\Entity\Element;
7
-use Muzich\CoreBundle\ElementFactory\ElementManager;
7
+use Muzich\CoreBundle\Managers\ElementManager;
8
 use Doctrine\Common\Collections\ArrayCollection;
8
 use Doctrine\Common\Collections\ArrayCollection;
9
 
9
 
10
 class ElementFactoryTest extends UnitTest
10
 class ElementFactoryTest extends UnitTest
122
     /*
122
     /*
123
      * - soundcloud.com
123
      * - soundcloud.com
124
      */
124
      */
125
-    $id = md5('http://soundcloud.com/matas/sets/library-project');
125
+    $url_id = 'http://soundcloud.com/matas/sets/library-project';
126
+    $embed_id = md5($url_id);
126
     $this->proceed_elementAndFill(
127
     $this->proceed_elementAndFill(
127
       $bux, 
128
       $bux, 
128
       'faez7tf8re9h4gf5j64dssz', 
129
       'faez7tf8re9h4gf5j64dssz', 
129
       'http://soundcloud.com/matas/sets/library-project', 
130
       'http://soundcloud.com/matas/sets/library-project', 
130
       array($hardtek->getId(), $tribe->getId()), 
131
       array($hardtek->getId(), $tribe->getId()), 
131
-      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
132
-          <param name="movie" value="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/sets/library-project&amp;enable_api=true&amp;object_id=embed_'.$id.'"></param>
132
+      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$embed_id.'" '
133
+          .'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
134
+          <param name="movie" value="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;'
135
+          .'enable_api=true&amp;object_id=embed_'.$embed_id.'"></param>
133
           <param name="allowscriptaccess" value="always"></param>
136
           <param name="allowscriptaccess" value="always"></param>
134
-          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" src="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/sets/library-project&amp;enable_api=true&amp;object_id=embed_'.$id.'" type="application/x-shockwave-flash" width="100%" name="embed_'.$id.'"></embed>
135
-        </object>
136
-        '
137
+          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" '
138
+          .'src="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;enable_api=true'
139
+          .'&amp;object_id=embed_'.$embed_id.'" type="application/x-shockwave-flash" '
140
+          .'width="100%" name="embed_'.$embed_id.'"></embed>
141
+        </object>'
137
     );
142
     );
138
     
143
     
139
-    $id = md5('http://soundcloud.com/matas/above-hyperion-redux');
144
+    $url_id = 'http://soundcloud.com/matas/above-hyperion-redux';
145
+    $embed_id = md5($url_id);
140
     $this->proceed_elementAndFill(
146
     $this->proceed_elementAndFill(
141
       $bux, 
147
       $bux, 
142
       'faez7tf8re9h4gf5j64dssz', 
148
       'faez7tf8re9h4gf5j64dssz', 
143
       'http://soundcloud.com/matas/above-hyperion-redux', 
149
       'http://soundcloud.com/matas/above-hyperion-redux', 
144
       array($hardtek->getId(), $tribe->getId()), 
150
       array($hardtek->getId(), $tribe->getId()), 
145
-      '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
146
-          <param name="movie" value="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/above-hyperion-redux&amp;enable_api=true&amp;object_id=embed_'.$id.'"></param>
151
+      
152
+        '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$embed_id.'" '
153
+          .'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
154
+          <param name="movie" value="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;'
155
+          .'enable_api=true&amp;object_id=embed_'.$embed_id.'"></param>
147
           <param name="allowscriptaccess" value="always"></param>
156
           <param name="allowscriptaccess" value="always"></param>
148
-          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" src="http://player.soundcloud.com/player.swf?url=http://soundcloud.com/matas/above-hyperion-redux&amp;enable_api=true&amp;object_id=embed_'.$id.'" type="application/x-shockwave-flash" width="100%" name="embed_'.$id.'"></embed>
149
-        </object>
150
-        '
157
+          <embed allowscriptaccess="always" height="'.$this->getParam('soundcloud_player_height').'" '
158
+          .'src="http://player.soundcloud.com/player.swf?url='.$url_id.'&amp;enable_api=true'
159
+          .'&amp;object_id=embed_'.$embed_id.'" type="application/x-shockwave-flash" '
160
+          .'width="100%" name="embed_'.$embed_id.'"></embed>
161
+        </object>'
151
     );
162
     );
152
     
163
     
153
     $this->proceed_elementAndFill(
164
     $this->proceed_elementAndFill(
183
       'gthyk456+liszz', 
194
       'gthyk456+liszz', 
184
       'http://www.jamendo.com/fr/album/30661', 
195
       'http://www.jamendo.com/fr/album/30661', 
185
       array($hardtek->getId(), $tribe->getId()), 
196
       array($hardtek->getId(), $tribe->getId()), 
186
-      '
187
-          <object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
197
+      
198
+        '<object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
199
+            .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
188
             <param name="allowScriptAccess" value="always" />
200
             <param name="allowScriptAccess" value="always" />
189
             <param name="wmode" value="transparent" />
201
             <param name="wmode" value="transparent" />
190
             <param name="movie" value="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" />
202
             <param name="movie" value="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" />
191
             <param name="quality" value="high" />
203
             <param name="quality" value="high" />
192
             <param name="bgcolor" value="#FFFFFF" />
204
             <param name="bgcolor" value="#FFFFFF" />
193
-            <embed src="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
205
+            <embed src="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF"'
206
+            .' width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always"'
207
+            .' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
194
               &nbsp;
208
               &nbsp;
195
             </embed>
209
             </embed>
196
             &nbsp;
210
             &nbsp;
197
-          </object>
198
-          <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
199
-        '
211
+          </object>' 
200
     );
212
     );
201
     
213
     
202
     $this->proceed_elementAndFill(
214
     $this->proceed_elementAndFill(
204
       'gthyk456+liszz', 
216
       'gthyk456+liszz', 
205
       'http://www.jamendo.com/fr/track/207079', 
217
       'http://www.jamendo.com/fr/track/207079', 
206
       array($hardtek->getId(), $tribe->getId()), 
218
       array($hardtek->getId(), $tribe->getId()), 
207
-      '
208
-          <object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
219
+      
220
+      '<object width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
221
+      .' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" align="middle">
209
             <param name="allowScriptAccess" value="always" />
222
             <param name="allowScriptAccess" value="always" />
210
             <param name="wmode" value="transparent" />
223
             <param name="wmode" value="transparent" />
211
-            <param name="movie" value="http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=207079" />
224
+            <param name="movie" value="http://widgets.jamendo.com/fr/track/?track_id=207079&playertype=2008" />
212
             <param name="quality" value="high" />
225
             <param name="quality" value="high" />
213
             <param name="bgcolor" value="#FFFFFF" />
226
             <param name="bgcolor" value="#FFFFFF" />
214
-            <embed src="http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=207079" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
227
+            <embed src="http://widgets.jamendo.com/fr/track/?track_id=207079&playertype=2008" quality="high" wmode="transparent" bgcolor="#FFFFFF"'
228
+      .' width="'.$this->getParam('jamendo_player_width').'" height="'.$this->getParam('jamendo_player_height').'" align="middle" allowScriptAccess="always"'
229
+      .' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
215
               &nbsp;
230
               &nbsp;
216
             </embed>
231
             </embed>
217
             &nbsp;
232
             &nbsp;
218
-          </object>
219
-          <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
220
-        '
233
+          </object>' 
221
     );
234
     );
222
     
235
     
223
     $this->proceed_elementAndFill(
236
     $this->proceed_elementAndFill(

+ 1 - 1
src/Muzich/CoreBundle/lib/UnitTest.php View File

4
 
4
 
5
 require_once(__DIR__ . "/../../../../app/AppKernel.php");
5
 require_once(__DIR__ . "/../../../../app/AppKernel.php");
6
 use Muzich\CoreBundle\Entity\Element;
6
 use Muzich\CoreBundle\Entity\Element;
7
-use Muzich\CoreBundle\ElementFactory\ElementManager;
7
+use Muzich\CoreBundle\Managers\ElementManager;
8
 
8
 
9
 class UnitTest extends \PHPUnit_Framework_TestCase
9
 class UnitTest extends \PHPUnit_Framework_TestCase
10
 {
10
 {