Quellcode durchsuchen

Anomalie #733: Url non géré

Sevajol Bastien vor 11 Jahren
Ursprung
Commit
8e2f96030f

+ 9 - 0
src/Muzich/CoreBundle/Factory/Elements/Soundcloudcom.php Datei anzeigen

@@ -20,10 +20,19 @@ class Soundcloudcom extends ElementFactory
20 20
   
21 21
   public function proceedDatas()
22 22
   {
23
+    $this->cleanUrl();
23 24
     $this->setElementDatasWithApi();
24 25
     $this->proceedThumbnailUrl();
25 26
   }
26 27
   
28
+  protected function cleanUrl()
29
+  {
30
+    if (strpos($this->element->getUrl(), '#') !== false)
31
+    {
32
+      $this->element->setUrl(substr($this->element->getUrl(), 0, strpos($this->element->getUrl(), '#')));
33
+    }
34
+  }
35
+  
27 36
   protected function setElementDatasWithApi()
28 37
   {
29 38
     if (($response = $this->getApiDatasResponse()))

+ 26 - 0
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php Datei anzeigen

@@ -354,6 +354,32 @@ class ElementFactoryTest extends UnitTest
354 354
       'data_normalized_url' => 'http://api.soundcloud.com/tracks/3154252'
355 355
     ),$datas);
356 356
     
357
+    
358
+    // https://soundcloud.com/sinkane/okay-africa-mixtape-2011#play
359
+    $datas = $this->proceed_element_datas_api(
360
+      $bux, 
361
+      'https://soundcloud.com/sinkane/okay-africa-mixtape-2011#play'
362
+    );
363
+    
364
+    $this->assertTrue(array_key_exists('data_thumb_url', $datas));
365
+    
366
+    if (array_key_exists('data_thumb_url', $datas))
367
+    {
368
+      unset($datas['data_thumb_url']);
369
+    }
370
+    
371
+    $this->assertEquals(array(
372
+      'data_ref_id' => 29186819,
373
+      'data_title' => 'Okay Africa Mixtape 2011',
374
+      //'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000001536693-gb1n5v-large.jpg?51826bf',
375
+      'data_type' => 'track',
376
+      'data_artist' => 'Sinkane',
377
+      'data_tags' => array(
378
+        0 => null
379
+      ),
380
+      'data_normalized_url' => 'http://api.soundcloud.com/tracks/29186819',
381
+    ),$datas);
382
+    
357 383
     // 'http://soundcloud.com/tracks/search?q%5Bfulltext%5D=EEK+A+MOUSSE&q%5Btype%5D=&q%5Bduration%5D='
358 384
     
359 385
     $this->assertEquals(array(

+ 3 - 0
src/Muzich/CoreBundle/Tests/ElementFactory/UrlAnalyzerTest.php Datei anzeigen

@@ -57,6 +57,9 @@ class UrlAnalyzerTest extends \PHPUnit_Framework_TestCase
57 57
     $url_analyzer = new UrlAnalyzer($this->getNewElement('soundcloud.com', 'http://soundcloud.com/user4818423/mechanika-crew-andrew-dj-set'), UrlMatchs::$soundcloud);
58 58
     $this->assertTrue($url_analyzer->haveMatch());
59 59
     
60
+    $url_analyzer = new UrlAnalyzer($this->getNewElement('soundcloud.com', 'https://soundcloud.com/sinkane/okay-africa-mixtape-2011#play'), UrlMatchs::$soundcloud);
61
+    $this->assertTrue($url_analyzer->haveMatch());
62
+    
60 63
     $url_analyzer = new UrlAnalyzer($this->getNewElement('soundcloud.com', 'https://soundcloud.com/search?q=toto'), UrlMatchs::$soundcloud);
61 64
     $this->assertFalse($url_analyzer->haveMatch());
62 65
   }