Example #1
0
 /**
  * Checks if all valid urls are correctly detected
  * @medium
  */
 protected function validateDetection($s, array $validUrls, array $invalidUrls)
 {
     $oembed = new MockOembed(new MockHttpRequest());
     $p = new \Embera\Providers(array('oembed' => true), $oembed);
     $this->assertCount(count($validUrls), $p->getAll($validUrls), $s . ' The valid Urls dont seem to be detected correctly');
     $p = new \Embera\Providers(array('oembed' => true), $oembed);
     $this->assertCount(count($validUrls), $p->getAll(array_merge($validUrls, $invalidUrls)), $s . ' There is at least one invalid url recognized as valid');
     $p = new \Embera\Providers(array('oembed' => true), $oembed);
     $this->assertCount(1, $p->getAll($validUrls[mt_rand(0, count($validUrls) - 1)]), $s . ' One Correct url seems to be invalid');
 }
Example #2
0
 public function testCustomProvider()
 {
     $oembed = new MockOembed(new MockHttpRequest());
     $customParams = array('apikey' => 'myapikey');
     $urls = array('http://customservice.com/9879837498', 'http://host.com/stuff/yes', 'http://customservice.com/hi', 'http://www.customservice.com/98756478', 'http://customservice.com/9879837498/');
     $p = new \Embera\Providers(array('oembed' => true), $oembed);
     $p->addProvider('www.customservice.com', 'CustomService', $customParams);
     $this->assertCount(3, $p->getAll($urls));
     $all = $p->getAll($urls);
     foreach ($all as $s) {
         $params = array_filter($s->getParams());
         $this->assertEquals($params, $customParams);
     }
 }