ElementFactoryTest.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. namespace Muzich\CoreBundle\Tests\Searcher;
  3. use Muzich\CoreBundle\lib\UnitTest;
  4. use Muzich\CoreBundle\Entity\Element;
  5. use Muzich\CoreBundle\ElementFactory\ElementManager;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. class ElementFactoryTest extends UnitTest
  8. {
  9. /**
  10. * Test du fonctionnement du l'usine
  11. * C'est plus un test fusible car il ne test que la méthode proceedFill.
  12. *
  13. */
  14. public function testEngine()
  15. {
  16. $r = $this->getDoctrine();
  17. $bux = $r->getRepository('MuzichCoreBundle:User')
  18. ->findOneByUsername('bux')
  19. ;
  20. $hardtek = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  21. $tribe = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  22. $youtube_width = '590';
  23. $youtube_height = '300';
  24. $element = new Element();
  25. $element->setName('Mon bel element');
  26. $element->setTags(json_encode(array($hardtek->getId(), $tribe->getId())));
  27. $element->setUrl('http://www.youtube.com/watch?v=WC8qb_of04E');
  28. $factory = new ElementManager($element, $r->getEntityManager(), $this->_container);
  29. $factory->proceedFill($bux);
  30. $url = 'http://www.youtube.com/embed/WC8qb_of04E';
  31. $this->assertEquals($element->getName(), 'Mon bel element');
  32. $this->assertEquals($element->getUrl(), 'http://www.youtube.com/watch?v=WC8qb_of04E');
  33. $this->assertEquals($element->getTags(), array($hardtek, $tribe));
  34. $this->assertEquals($element->getEmbed(),
  35. '<iframe width="'.$youtube_width.'" height="'.$youtube_height.'" src="'.$url.'" '
  36. .'frameborder="0" allowfullscreen></iframe>'
  37. );
  38. }
  39. /**
  40. * Test des création de code embed
  41. */
  42. public function testEmbedsEngine()
  43. {
  44. $r = $this->getDoctrine();
  45. $bux = $r->getRepository('MuzichCoreBundle:User')
  46. ->findOneByUsername('bux')
  47. ;
  48. $hardtek = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  49. $tribe = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  50. /*
  51. * - youtube.com && youtu.be
  52. */
  53. $this->proceed_elementAndFill(
  54. $bux,
  55. 'dfd4z5d3s45sgf45645',
  56. 'http://www.youtube.com/watch?v=Itfg7UpkcSs&feature=g-vrec&context=G2e61726RVAAAAAAAAAg',
  57. array($hardtek->getId(), $tribe->getId()),
  58. '<iframe width="'.$this->getParam('youtube_player_width').'" '
  59. .'height="'.$this->getParam('youtube_player_height').'" '
  60. .'src="http://www.youtube.com/embed/Itfg7UpkcSs" '
  61. .'frameborder="0" allowfullscreen></iframe>'
  62. );
  63. $this->proceed_elementAndFill(
  64. $bux,
  65. 'dfd4z5d3s45sgf45645',
  66. 'http://www.youtube.com/watch?feature=player_detailpage&v=Itfg7UpkcSs#t=3s',
  67. array($hardtek->getId(), $tribe->getId()),
  68. '<iframe width="'.$this->getParam('youtube_player_width').'" '
  69. .'height="'.$this->getParam('youtube_player_height').'" '
  70. .'src="http://www.youtube.com/embed/Itfg7UpkcSs" '
  71. .'frameborder="0" allowfullscreen></iframe>'
  72. );
  73. $this->proceed_elementAndFill(
  74. $bux,
  75. 'dfd4z5d3s45sgf45645',
  76. 'http://youtu.be/Itfg7UpkcSs',
  77. array($hardtek->getId(), $tribe->getId()),
  78. '<iframe width="'.$this->getParam('youtube_player_width').'" '
  79. .'height="'.$this->getParam('youtube_player_height').'" '
  80. .'src="http://www.youtube.com/embed/Itfg7UpkcSs" '
  81. .'frameborder="0" allowfullscreen></iframe>'
  82. );
  83. $this->proceed_elementAndFill(
  84. $bux,
  85. 'dfd4z5d3s45sgf45645',
  86. 'http://www.youtube.com/watch?v=Itfg7UpkcSs',
  87. array($hardtek->getId(), $tribe->getId()),
  88. '<iframe width="'.$this->getParam('youtube_player_width').'" '
  89. .'height="'.$this->getParam('youtube_player_height').'" '
  90. .'src="http://www.youtube.com/embed/Itfg7UpkcSs" '
  91. .'frameborder="0" allowfullscreen></iframe>'
  92. );
  93. /*
  94. * - dailymotion.com
  95. */
  96. $this->proceed_elementAndFill(
  97. $bux,
  98. 'fzgrj79ukl46ye4rgz6a',
  99. 'http://www.dailymotion.com/video/xafj1q_black-bomb-a-tales-from-the-old-sch_music',
  100. array($hardtek->getId(), $tribe->getId()),
  101. '<iframe frameborder="0" width="'.$this->getParam('dailymotion_player_width').'" '
  102. .'height="'.$this->getParam('dailymotion_player_height').'" '
  103. .'src="http://www.dailymotion.com/embed/video/xafj1q"></iframe>'
  104. );
  105. /*
  106. * - soundcloud.com
  107. */
  108. $id = md5('http://soundcloud.com/matas/sets/library-project');
  109. $this->proceed_elementAndFill(
  110. $bux,
  111. 'faez7tf8re9h4gf5j64dssz',
  112. 'http://soundcloud.com/matas/sets/library-project',
  113. array($hardtek->getId(), $tribe->getId()),
  114. '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
  115. <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>
  116. <param name="allowscriptaccess" value="always"></param>
  117. <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>
  118. </object>
  119. '
  120. );
  121. $id = md5('http://soundcloud.com/matas/above-hyperion-redux');
  122. $this->proceed_elementAndFill(
  123. $bux,
  124. 'faez7tf8re9h4gf5j64dssz',
  125. 'http://soundcloud.com/matas/above-hyperion-redux',
  126. array($hardtek->getId(), $tribe->getId()),
  127. '<object height="'.$this->getParam('soundcloud_player_height').'" width="100%" id="embed_'.$id.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
  128. <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>
  129. <param name="allowscriptaccess" value="always"></param>
  130. <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>
  131. </object>
  132. '
  133. );
  134. $this->proceed_elementAndFill(
  135. $bux,
  136. 'faez7tf8re9h4gf5j64dssz',
  137. 'http://soundcloud.com/tracks/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D=',
  138. array($hardtek->getId(), $tribe->getId()),
  139. null
  140. );
  141. $this->proceed_elementAndFill(
  142. $bux,
  143. 'faez7tf8re9h4gf5j64dssz',
  144. 'http://soundcloud.com/people/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D=',
  145. array($hardtek->getId(), $tribe->getId()),
  146. null
  147. );
  148. $this->proceed_elementAndFill(
  149. $bux,
  150. 'faez7tf8re9h4gf5j64dssz',
  151. 'http://soundcloud.com/groups/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D=',
  152. array($hardtek->getId(), $tribe->getId()),
  153. null
  154. );
  155. /*
  156. * - jamendo.com
  157. */
  158. $this->proceed_elementAndFill(
  159. $bux,
  160. 'gthyk456+liszz',
  161. 'http://www.jamendo.com/fr/album/30661',
  162. array($hardtek->getId(), $tribe->getId()),
  163. '
  164. <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">
  165. <param name="allowScriptAccess" value="always" />
  166. <param name="wmode" value="transparent" />
  167. <param name="movie" value="http://widgets.jamendo.com/fr/album/?album_id=30661&playertype=2008" />
  168. <param name="quality" value="high" />
  169. <param name="bgcolor" value="#FFFFFF" />
  170. <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">
  171. &nbsp;
  172. </embed>
  173. &nbsp;
  174. </object>
  175. <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
  176. '
  177. );
  178. $this->proceed_elementAndFill(
  179. $bux,
  180. 'gthyk456+liszz',
  181. 'http://www.jamendo.com/fr/track/207079',
  182. array($hardtek->getId(), $tribe->getId()),
  183. '
  184. <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">
  185. <param name="allowScriptAccess" value="always" />
  186. <param name="wmode" value="transparent" />
  187. <param name="movie" value="http://widgets.jamendo.com/fr/track/?playertype=2008&track_id=207079" />
  188. <param name="quality" value="high" />
  189. <param name="bgcolor" value="#FFFFFF" />
  190. <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">
  191. &nbsp;
  192. </embed>
  193. &nbsp;
  194. </object>
  195. <a href="http://pro.jamendo.com/" style="display:block;font-size:8px !important;">Catalogue professionnel de musique libre</a>
  196. '
  197. );
  198. $this->proceed_elementAndFill(
  199. $bux,
  200. 'gthyk456+liszz',
  201. 'http://www.jamendo.com/fr/search/all/psytrance',
  202. array($hardtek->getId(), $tribe->getId()),
  203. null
  204. );
  205. $this->proceed_elementAndFill(
  206. $bux,
  207. 'gthyk456+liszz',
  208. 'http://www.jamendo.com/fr/artist/DJ_BETO',
  209. array($hardtek->getId(), $tribe->getId()),
  210. null
  211. );
  212. /*/*
  213. * - deezer.com
  214. */
  215. $this->proceed_elementAndFill(
  216. $bux,
  217. 'a9j4l56dsu8ra5gf647je',
  218. 'http://www.deezer.com/fr/music/pantera/far-beyond-driven-80398',
  219. array($hardtek->getId(), $tribe->getId()),
  220. '<iframe scrolling="no" frameborder="0" allowTransparency="true" '
  221. .'src="http://www.deezer.com/fr/plugins/player?autoplay=false&playlist=true'
  222. .'&width='.$this->getParam('deezer_player_width').'&height='
  223. .$this->getParam('deezer_player_height')
  224. .'&cover=true&btn_popup=true&type=album&id=80398&title=" '
  225. .'width="'.$this->getParam('deezer_player_width').'" height="'
  226. .$this->getParam('deezer_player_height')
  227. .'"></iframe>'
  228. );
  229. $this->proceed_elementAndFill(
  230. $bux,
  231. 'g4th4545ku6kti456e456z',
  232. 'http://www.deezer.com/fr/music/playlist/18701350',
  233. array($hardtek->getId(), $tribe->getId()),
  234. '<iframe scrolling="no" frameborder="0" allowTransparency="true" '
  235. .'src="http://www.deezer.com/fr/plugins/player?autoplay=false&playlist=true'
  236. .'&width='.$this->getParam('deezer_player_width').'&height='
  237. .$this->getParam('deezer_player_height')
  238. .'&cover=true&btn_popup=true&type=playlist&id=18701350&title=" '
  239. .'width="'.$this->getParam('deezer_player_width').'" height="'
  240. .$this->getParam('deezer_player_height')
  241. .'"></iframe>'
  242. );
  243. }
  244. }