3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
11 require_once INSTALLDIR . '/lib/common.php';
13 class oEmbedTest extends PHPUnit_Framework_TestCase
16 public function setup()
18 //$this->old_oohembed = common_config('oohembed', 'endpoint');
21 public function tearDown()
23 //$GLOBALS['config']['attachments']['supported'] = $this->old_attachments_supported;
27 * @dataProvider fallbackSources
30 public function testoEmbed($url, $expectedType)
33 $data = oEmbedHelper::getObject($url);
34 $this->assertEquals($expectedType, $data->type);
35 } catch (Exception $e) {
36 if ($expectedType == 'none') {
37 $this->assertEquals($expectedType, 'none', 'Should not have data for this URL.');
45 * Sample oEmbed targets for sites we know ourselves...
48 static public function knownSources()
51 array('http://www.flickr.com/photos/brionv/5172500179/', 'photo'),
52 array('http://yfrog.com/fy42747177j', 'photo'),
53 array('http://twitpic.com/36adw6', 'photo'),
59 * Sample oEmbed targets that can be found via discovery.
60 * Includes also knownSources() output.
64 static public function discoverableSources()
67 array('http://identi.ca/attachment/34437400', 'photo'),
69 array('http://www.youtube.com/watch?v=eUgLR232Cnw', 'video'),
70 array('http://vimeo.com/9283184', 'video'),
72 // Will fail discovery:
73 array('http://leuksman.com/log/2010/10/29/statusnet-0-9-6-release/', 'none'),
75 return array_merge(self::knownSources(), $sources);
79 * Sample oEmbed targets that can be found via oohembed.com.
80 * Includes also discoverableSources() output.
84 static public function fallbackSources()
87 array('http://en.wikipedia.org/wiki/File:Wiki.png', 'link'), // @fixme in future there may be a native provider -- will change to 'photo'
89 return array_merge(self::discoverableSources(), $sources);