Autoload.php
9 years ago
TestEmbera.php
9 years ago
TestFakeResponse.php
9 years ago
TestFormatter.php
9 years ago
TestHttpRequest.php
9 years ago
TestOembed.php
9 years ago
TestProviders.php
9 years ago
TestServiceAmCharts.php
9 years ago
TestServiceAnimatron.php
9 years ago
TestServiceAnimoto.php
9 years ago
TestServiceAolOn.php
9 years ago
TestServiceAppNet.php
9 years ago
TestServiceAudioSnaps.php
9 years ago
TestServiceBambuser.php
9 years ago
TestServiceBlipTv.php
9 years ago
TestServiceCacoo.php
9 years ago
TestServiceChartblocks.php
9 years ago
TestServiceChirbit.php
9 years ago
TestServiceCircuitLab.php
9 years ago
TestServiceClyp.php
9 years ago
TestServiceCodepoints.php
9 years ago
TestServiceCollegeHumor.php
9 years ago
TestServiceCoub.php
9 years ago
TestServiceCrowdRanking.php
9 years ago
TestServiceDailyMile.php
9 years ago
TestServiceDailyMotion.php
9 years ago
TestServiceDeviantart.php
9 years ago
TestServiceDipity.php
9 years ago
TestServiceDotSub.php
9 years ago
TestServiceEdocr.php
9 years ago
TestServiceEgliseInfo.php
9 years ago
TestServiceFacebook.php
9 years ago
TestServiceFlickr.php
9 years ago
TestServiceFunnyOrDie.php
9 years ago
TestServiceGeographCI.php
9 years ago
TestServiceGeographDe.php
9 years ago
TestServiceGeographUk.php
9 years ago
TestServiceGettyImages.php
9 years ago
TestServiceGfycat.php
9 years ago
TestServiceGithubGist.php
9 years ago
TestServiceGmep.php
9 years ago
TestServiceHq23.php
9 years ago
TestServiceHuffduffer.php
9 years ago
TestServiceHulu.php
9 years ago
TestServiceIFTTT.php
9 years ago
TestServiceIFixIt.php
9 years ago
TestServiceInfogram.php
9 years ago
TestServiceInstagram.php
9 years ago
TestServiceIssuu.php
9 years ago
TestServiceIssuuFakeResponse.php
9 years ago
TestServiceKickstarter.php
9 years ago
TestServiceLearningApps.php
9 years ago
TestServiceMeetup.php
9 years ago
TestServiceMixCloud.php
9 years ago
TestServiceMobyPicture.php
9 years ago
TestServiceNFB.php
9 years ago
TestServiceOfficeMix.php
9 years ago
TestServiceOfficialFM.php
9 years ago
TestServiceOumy.php
9 years ago
TestServicePastery.php
9 years ago
TestServicePollDaddy.php
9 years ago
TestServicePollEverywhere.php
9 years ago
TestServicePortfolium.php
9 years ago
TestServiceRapidengage.php
9 years ago
TestServiceRdio.php
9 years ago
TestServiceReleaseWire.php
9 years ago
TestServiceRepubHub.php
9 years ago
TestServiceReverbnation.php
9 years ago
TestServiceRevision3.php
9 years ago
TestServiceRoomshare.php
9 years ago
TestServiceRutube.php
9 years ago
TestServiceSapo.php
9 years ago
TestServiceScreenr.php
9 years ago
TestServiceScribd.php
9 years ago
TestServiceShortNote.php
9 years ago
TestServiceShoudio.php
9 years ago
TestServiceShowTheWay.php
9 years ago
TestServiceSilk.php
9 years ago
TestServiceSketchfab.php
9 years ago
TestServiceSlideshare.php
9 years ago
TestServiceSoundCloud.php
9 years ago
TestServiceSpeakerDeck.php
9 years ago
TestServiceSpotify.php
9 years ago
TestServiceSway.php
9 years ago
TestServiceTed.php
9 years ago
TestServiceTheySaidSo.php
9 years ago
TestServiceTwitter.php
9 years ago
TestServiceUstream.php
9 years ago
TestServiceVerse.php
9 years ago
TestServiceViddler.php
9 years ago
TestServiceVideoFork.php
9 years ago
TestServiceVideoJug.php
9 years ago
TestServiceVimeo.php
9 years ago
TestServiceVine.php
9 years ago
TestServiceWordpressTV.php
9 years ago
TestServiceYFrog.php
9 years ago
TestServiceYandex.php
9 years ago
TestServiceYoutube.php
9 years ago
TestUrl.php
9 years ago
TestOembed.php
76 lines
| 1 | <?php |
| 2 | /** |
| 3 | * TestOembed.php |
| 4 | * |
| 5 | * @package Tests |
| 6 | * @author Michael Pratt <pratt@hablarmierda.net> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | class TestOembed extends PHPUnit_Framework_TestCase |
| 14 | { |
| 15 | public function testResourceInfoOembedDisabled() |
| 16 | { |
| 17 | $oembed = new \Embera\Oembed(new MockHttpRequest()); |
| 18 | $return = $oembed->getResourceInfo(true, 'dummyurl1', 'dummyurl2'); |
| 19 | $this->assertEquals($return, array()); |
| 20 | } |
| 21 | |
| 22 | public function testResourceInfoOembedJson() |
| 23 | { |
| 24 | $value = array('value1' => 10, 'value2' => 30); |
| 25 | |
| 26 | $http = new MockHttpRequest(); |
| 27 | $http->response = json_encode($value); |
| 28 | |
| 29 | $oembed = new \Embera\Oembed($http); |
| 30 | $return = $oembed->getResourceInfo(true, 'dummyurl', 'dummy_url2'); |
| 31 | unset($return['embera_using_fake']); |
| 32 | |
| 33 | $this->assertEquals($return, $value); |
| 34 | } |
| 35 | |
| 36 | public function testResourceInfoOembedInvalidJson() |
| 37 | { |
| 38 | $value = 'this text is not a json object'; |
| 39 | |
| 40 | $http = new MockHttpRequest(); |
| 41 | $http->response = $value; |
| 42 | |
| 43 | $oembed = new \Embera\Oembed($http); |
| 44 | $return = $oembed->getResourceInfo(true, 'dummyurl', 'dummy_url2'); |
| 45 | $this->assertEquals($return, array()); |
| 46 | } |
| 47 | |
| 48 | public function testUrlConstruction() |
| 49 | { |
| 50 | $oembed = new \Embera\Oembed(new MockHttpRequest()); |
| 51 | $reflection = new ReflectionClass('\Embera\Oembed'); |
| 52 | $method = $reflection->getMethod('constructUrl'); |
| 53 | $method->setAccessible(true); |
| 54 | |
| 55 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com/', array('house' => '1', 'value2' => '3', 'format' => 'json')), |
| 56 | 'http://www.apiurl.com/?house=1&value2=3&format=json'); |
| 57 | |
| 58 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com', array('width' => '100', 'format' => 'xml')), |
| 59 | 'http://www.apiurl.com?width=100&format=xml'); |
| 60 | |
| 61 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com/?url=100', array('maxheight' => 400, 'format' => 'json')), |
| 62 | 'http://www.apiurl.com/?url=100&maxheight=400&format=json'); |
| 63 | |
| 64 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com/hellow/', array('format' => 'json')), |
| 65 | 'http://www.apiurl.com/hellow/?format=json'); |
| 66 | |
| 67 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com/', array('height' => '2000')), |
| 68 | 'http://www.apiurl.com/?height=2000'); |
| 69 | |
| 70 | $this->assertEquals($method->invoke($oembed, 'http://www.apiurl.com/', array()), |
| 71 | 'http://www.apiurl.com/?'); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | ?> |
| 76 |