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
TestFormatter.php
123 lines
| 1 | <?php |
| 2 | /** |
| 3 | * TestFormatter.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 TestFormatter extends PHPUnit_Framework_TestCase |
| 14 | { |
| 15 | public function testTemplateArray() |
| 16 | { |
| 17 | $urls = array( |
| 18 | 'http://youtu.be/fSUK4WgQ3vk', |
| 19 | 'http://www.youtube.com/watch?v=T3O1nffTG-k' |
| 20 | ); |
| 21 | |
| 22 | $embera = new \Embera\Embera(); |
| 23 | $embera = new \Embera\Formatter($embera); |
| 24 | $embera->setTemplate('{html}|'); |
| 25 | |
| 26 | $result = $embera->transform($urls); |
| 27 | $this->assertCount(count($urls), explode('|', trim($result, '|'))); |
| 28 | } |
| 29 | |
| 30 | public function testTemplateString() |
| 31 | { |
| 32 | $embera = new \Embera\Embera(); |
| 33 | $embera = new \Embera\Formatter($embera); |
| 34 | $embera->setTemplate('<div class="hey">{html}</div>'); |
| 35 | $result = $embera->transform('Hey did you see http://www.youtube.com/watch?v=MpVHQnIvTXo'); |
| 36 | |
| 37 | $this->assertContains('<div class="hey"><iframe', $result); |
| 38 | } |
| 39 | |
| 40 | public function testOfflineSupport() |
| 41 | { |
| 42 | $urls = array( |
| 43 | 'http://www.youtube.com/watch?v=MpVHQnIvTXo', |
| 44 | 'http://youtu.be/fSUK4WgQ3vk', |
| 45 | ); |
| 46 | |
| 47 | $embera = new \Embera\Embera(array('oembed' => false)); |
| 48 | $embera = new \Embera\Formatter($embera); |
| 49 | $embera->setTemplate('<div class="hi">{html}</div>'); |
| 50 | |
| 51 | $result = $embera->transform($urls); |
| 52 | $this->assertEmpty($result); |
| 53 | $this->assertTrue($embera->hasErrors()); |
| 54 | $this->assertCount(count($urls), $embera->getErrors()); |
| 55 | |
| 56 | $last = $embera->getLastError(); |
| 57 | $this->assertTrue(!empty($last)); |
| 58 | } |
| 59 | |
| 60 | public function testOfflineSupport2() |
| 61 | { |
| 62 | $urls = array('http://youtu.be/fSUK4WgQ3vk'); |
| 63 | |
| 64 | $embera = new \Embera\Embera(array('oembed' => false)); |
| 65 | $embera = new \Embera\Formatter($embera, true); |
| 66 | $embera->setTemplate('<div class="hi">{html}</div>'); |
| 67 | |
| 68 | $result = $embera->transform($urls); |
| 69 | $this->assertContains('<iframe', $result); |
| 70 | } |
| 71 | |
| 72 | public function testSupportForDecoratedObjectAPI() |
| 73 | { |
| 74 | $urls = array( |
| 75 | 'http://www.youtube.com/watch?v=MpVHQnIvTXo', |
| 76 | 'http://youtu.be/fSUK4WgQ3vk', |
| 77 | ); |
| 78 | |
| 79 | $embera = new \Embera\Embera(array('oembed' => false)); |
| 80 | $embera = new \Embera\Formatter($embera); |
| 81 | |
| 82 | $result = $embera->autoEmbed(implode(' ', $urls)); |
| 83 | $this->assertTrue(!empty($result)); |
| 84 | $this->assertContains('<iframe', $result); |
| 85 | } |
| 86 | |
| 87 | public function testSupportForDecoratedObjectAPI2() |
| 88 | { |
| 89 | $this->setExpectedException('InvalidArgumentException'); |
| 90 | |
| 91 | $embera = new \Embera\Embera(array('oembed' => false)); |
| 92 | $embera = new \Embera\Formatter($embera); |
| 93 | |
| 94 | $last = $embera->getLastError(); |
| 95 | $this->assertTrue(empty($last)); |
| 96 | |
| 97 | $embera->unknownMethodName(); |
| 98 | } |
| 99 | |
| 100 | public function testUnknownWebsites() |
| 101 | { |
| 102 | $embera = new \Embera\Embera(); |
| 103 | $embera = new \Embera\Formatter($embera); |
| 104 | |
| 105 | $this->assertEmpty($embera->setTemplate('{html}', array('url1.com', 'url2.com', 'url3.com'))); |
| 106 | $this->assertEquals($embera->setTemplate('{html}', 'unknown url http://hey.com'), 'unknown url http://hey.com'); |
| 107 | } |
| 108 | |
| 109 | public function testRemoveEmptyPlaceholders() |
| 110 | { |
| 111 | $urls = array('http://youtu.be/fSUK4WgQ3vk'); |
| 112 | |
| 113 | $embera = new \Embera\Embera(); |
| 114 | $embera = new \Embera\Formatter($embera); |
| 115 | $embera->setTemplate('{unknown_key}'); |
| 116 | |
| 117 | $result = $embera->transform($urls); |
| 118 | $this->assertEquals($result, ''); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | ?> |
| 123 |