]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - tests/oEmbedTest.php
Filling in missing endHTML calls for Action AJAX
[quix0rs-gnu-social.git] / tests / oEmbedTest.php
index d00963003e7e72dcf23d3a2d4656ec55a447eab7..1f1d5f826cba25f4899f7a6605d5596d96d9712b 100644 (file)
@@ -15,22 +15,22 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
 
     public function setup()
     {
-        $this->old_oohembed = common_config('oohembed', 'endpoint');
+        $this->old_ohembed = common_config('ohembed', 'endpoint');
     }
 
     public function tearDown()
     {
-        $GLOBALS['config']['oohembed']['endpoint'] = $this->old_oohembed;
+        $GLOBALS['config']['oembed']['endpoint'] = $this->old_ohembed;
     }
 
     /**
-     * Test with oohembed DISABLED.
+     * Test with ohembed DISABLED.
      *
      * @dataProvider discoverableSources
      */
     public function testoEmbed($url, $expectedType)
     {
-        $GLOBALS['config']['oohembed']['endpoint'] = false;
+        $GLOBALS['config']['oembed']['endpoint'] = false;
         $this->_doTest($url, $expectedType);
     }
 
@@ -39,14 +39,14 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
      *
      * @dataProvider fallbackSources
      */
-    public function testoohEmbed($url, $expectedType)
+    public function testnoEmbed($url, $expectedType)
     {
-        $GLOBALS['config']['oohembed']['endpoint'] = $this->_endpoint();
+        $GLOBALS['config']['oembed']['endpoint'] = $this->_endpoint();
         $this->_doTest($url, $expectedType);
     }
 
     /**
-     * Get default oohembed endpoint.
+     * Get default oembed endpoint.
      *
      * @return string
      */
@@ -55,7 +55,7 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
         $default = array();
         $_server = 'localhost'; $_path = '';
         require INSTALLDIR . '/lib/default.php';
-        return $default['oohembed']['endpoint'];
+        return $default['oembed']['endpoint'];
     }
 
     /**
@@ -69,6 +69,18 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
         try {
             $data = oEmbedHelper::getObject($url);
             $this->assertEquals($expectedType, $data->type);
+            if ($data->type == 'photo') {
+                $this->assertTrue(!empty($data->url), 'Photo must have a URL.');
+                $this->assertTrue(!empty($data->width), 'Photo must have a width.');
+                $this->assertTrue(!empty($data->height), 'Photo must have a height.');
+            } else if ($data->type == 'video') {
+                $this->assertTrue(!empty($data->html), 'Video must have embedding HTML.');
+                $this->assertTrue(!empty($data->thumbnail_url), 'Video should have a thumbnail.');
+            }
+            if (!empty($data->thumbnail_url)) {
+                $this->assertTrue(!empty($data->thumbnail_width), 'Thumbnail must list a width.');
+                $this->assertTrue(!empty($data->thumbnail_height), 'Thumbnail must list a height.');
+            }
         } catch (Exception $e) {
             if ($expectedType == 'none') {
                 $this->assertEquals($expectedType, 'none', 'Should not have data for this URL.');
@@ -101,7 +113,6 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
     static public function discoverableSources()
     {
         $sources = array(
-            array('http://identi.ca/attachment/34437400', 'photo'),
 
             array('http://www.youtube.com/watch?v=eUgLR232Cnw', 'video'),
             array('http://vimeo.com/9283184', 'video'),
@@ -113,16 +124,20 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Sample oEmbed targets that can be found via oohembed.com.
+     * Sample oEmbed targets that can be found via noembed.com.
      * Includes also discoverableSources() output.
      *
      * @return array
      */
     static public function fallbackSources()
     {
+
         $sources = array(
-            array('http://en.wikipedia.org/wiki/File:Wiki.png', 'link'), // @fixme in future there may be a native provider -- will change to 'photo'
+            array('https://github.com/git/git/commit/85e9c7e1d42849c5c3084a9da748608468310c0e', 'Github Commit'), // @fixme in future there may be a native provider -- will change to 'photo'
         );
+
+        $sources = array();
+
         return array_merge(self::discoverableSources(), $sources);
     }
 }