Autoload.php
8 years ago
TestEmbera.php
8 years ago
TestFakeResponse.php
8 years ago
TestFormatter.php
8 years ago
TestHtmlProcessor.php
8 years ago
TestHttpRequest.php
8 years ago
TestOembed.php
8 years ago
TestProviders.php
8 years ago
TestServiceAmCharts.php
8 years ago
TestServiceAnimatron.php
8 years ago
TestServiceAnimoto.php
8 years ago
TestServiceAolOn.php
8 years ago
TestServiceAppNet.php
8 years ago
TestServiceAudioSnaps.php
8 years ago
TestServiceBambuser.php
8 years ago
TestServiceBlipTv.php
8 years ago
TestServiceCacoo.php
8 years ago
TestServiceChartblocks.php
8 years ago
TestServiceChirbit.php
8 years ago
TestServiceCircuitLab.php
8 years ago
TestServiceClipland.php
8 years ago
TestServiceClyp.php
8 years ago
TestServiceCodepoints.php
8 years ago
TestServiceCollegeHumor.php
8 years ago
TestServiceCoub.php
8 years ago
TestServiceCrowdRanking.php
8 years ago
TestServiceDailyMile.php
8 years ago
TestServiceDailyMotion.php
8 years ago
TestServiceDeviantart.php
8 years ago
TestServiceDidacte.php
8 years ago
TestServiceDipity.php
8 years ago
TestServiceDotSub.php
8 years ago
TestServiceEdocr.php
8 years ago
TestServiceEgliseInfo.php
8 years ago
TestServiceFacebook.php
8 years ago
TestServiceFlickr.php
8 years ago
TestServiceFunnyOrDie.php
8 years ago
TestServiceGeographCI.php
8 years ago
TestServiceGeographDe.php
8 years ago
TestServiceGeographUk.php
8 years ago
TestServiceGettyImages.php
8 years ago
TestServiceGfycat.php
8 years ago
TestServiceGithubGist.php
8 years ago
TestServiceGmep.php
8 years ago
TestServiceHq23.php
8 years ago
TestServiceHuffduffer.php
8 years ago
TestServiceHulu.php
8 years ago
TestServiceIFTTT.php
8 years ago
TestServiceIFixIt.php
8 years ago
TestServiceInfogram.php
8 years ago
TestServiceInstagram.php
8 years ago
TestServiceIssuu.php
8 years ago
TestServiceIssuuFakeResponse.php
8 years ago
TestServiceKickstarter.php
8 years ago
TestServiceLearningApps.php
8 years ago
TestServiceMeetup.php
8 years ago
TestServiceMixCloud.php
8 years ago
TestServiceMobyPicture.php
8 years ago
TestServiceNFB.php
8 years ago
TestServiceOfficeMix.php
8 years ago
TestServiceOfficialFM.php
8 years ago
TestServiceOumy.php
8 years ago
TestServicePastery.php
8 years ago
TestServicePollDaddy.php
8 years ago
TestServicePollEverywhere.php
8 years ago
TestServicePortfolium.php
8 years ago
TestServiceRapidengage.php
8 years ago
TestServiceRdio.php
8 years ago
TestServiceReleaseWire.php
8 years ago
TestServiceRepubHub.php
8 years ago
TestServiceReverbnation.php
8 years ago
TestServiceRevision3.php
8 years ago
TestServiceRoomshare.php
8 years ago
TestServiceRutube.php
8 years ago
TestServiceSapo.php
8 years ago
TestServiceScreenr.php
8 years ago
TestServiceScribd.php
8 years ago
TestServiceShortNote.php
8 years ago
TestServiceShoudio.php
8 years ago
TestServiceShowTheWay.php
8 years ago
TestServiceSilk.php
8 years ago
TestServiceSketchfab.php
8 years ago
TestServiceSlideshare.php
8 years ago
TestServiceSoundCloud.php
8 years ago
TestServiceSpeakerDeck.php
8 years ago
TestServiceSpotify.php
8 years ago
TestServiceStreamOneCloud.php
8 years ago
TestServiceStreamable.php
8 years ago
TestServiceSway.php
8 years ago
TestServiceTed.php
8 years ago
TestServiceTheySaidSo.php
8 years ago
TestServiceTwitter.php
8 years ago
TestServiceUstream.php
8 years ago
TestServiceVerse.php
8 years ago
TestServiceVevo.php
8 years ago
TestServiceViddler.php
8 years ago
TestServiceVideoFork.php
8 years ago
TestServiceVideoJug.php
8 years ago
TestServiceVimeo.php
8 years ago
TestServiceVine.php
8 years ago
TestServiceWordpressTV.php
8 years ago
TestServiceYFrog.php
8 years ago
TestServiceYandex.php
8 years ago
TestServiceYoutube.php
8 years ago
TestUrl.php
8 years ago
TestHtmlProcessor.php
114 lines
| 1 | <?php |
| 2 | /** |
| 3 | * TestHtmlProcessor.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 TestHtmlProcessor extends PHPUnit_Framework_TestCase |
| 14 | { |
| 15 | public function testDontReplaceInsideDefaultTags() |
| 16 | { |
| 17 | $expected = array( |
| 18 | '<a href="http://youtu.be/fSUK4WgQ3vk" title="">http://youtu.be/fSUK4WgQ3vk</a>', |
| 19 | '<iframe width="420" height="315" src="//www.youtube.com/embed/fSUK4WgQ3vk" frameborder="0" allowfullscreen></iframe>', |
| 20 | '<a href="http://youtu.be/fSUK4WgQ3vk">other link</a>', |
| 21 | '<img src="http://youtu.be/fSUK4WgQ3vk" alt="" />', |
| 22 | '<iframe width="420" height="315" src="//www.youtube.com/embed/fSUK4WgQ3vk" frameborder="0" allowfullscreen></iframe>', |
| 23 | '<img src="http://youtu.be/fSUK4WgQ3vk" title="">', |
| 24 | '<pre>My House http://youtu.be/fSUK4WgQ3vk </pre>', |
| 25 | '<code>http://youtu.be/fSUK4WgQ3vk</code>', |
| 26 | ); |
| 27 | |
| 28 | $data = array( |
| 29 | '<a href="http://youtu.be/fSUK4WgQ3vk" title="">http://youtu.be/fSUK4WgQ3vk</a>', |
| 30 | 'http://youtu.be/fSUK4WgQ3vk', |
| 31 | '<a href="http://youtu.be/fSUK4WgQ3vk">other link</a>', |
| 32 | '<img src="http://youtu.be/fSUK4WgQ3vk" alt="" />', |
| 33 | 'http://youtu.be/fSUK4WgQ3vk', |
| 34 | '<img src="http://youtu.be/fSUK4WgQ3vk" title="">', |
| 35 | '<pre>My House http://youtu.be/fSUK4WgQ3vk </pre>', |
| 36 | '<code>http://youtu.be/fSUK4WgQ3vk</code>', |
| 37 | ); |
| 38 | |
| 39 | $embera = new \Embera\Embera(array('oembed' => false)); |
| 40 | $result = $embera->autoEmbed(implode(', ', $data)); |
| 41 | |
| 42 | $this->assertEquals($result, implode(', ', $expected)); |
| 43 | } |
| 44 | |
| 45 | public function testDontReplaceNestedContent() |
| 46 | { |
| 47 | $expected = array( |
| 48 | '<a href="http://myurl.com" title="">http://myurl.com</a>', |
| 49 | 'replaced', |
| 50 | '<pre> <img src="http://myurl.com" title=""> Check Out My Url <a href="http://myurl.com" title="">http://myurl.com <img src="http://myurl.com" title=""/></a></pre>', |
| 51 | ); |
| 52 | |
| 53 | $data = array( |
| 54 | '<a href="http://myurl.com" title="">http://myurl.com</a>', |
| 55 | 'http://myurl.com', |
| 56 | '<pre> <img src="http://myurl.com" title=""> Check Out My Url <a href="http://myurl.com" title="">http://myurl.com <img src="http://myurl.com" title=""/></a></pre>', |
| 57 | ); |
| 58 | |
| 59 | $p = new \Embera\HtmlProcessor(array('a', 'pre', 'img', 'code'), array('http://myurl.com' => 'replaced')); |
| 60 | $result = $p->process(implode(', ', $data)); |
| 61 | |
| 62 | $this->assertEquals($result, implode(', ', $expected)); |
| 63 | } |
| 64 | |
| 65 | public function testDontReplaceNestedContentAdvanced() |
| 66 | { |
| 67 | $html = '<code> |
| 68 | <a href="http://myurl.com" title="">http://myurl.com <img src="http://myurl.com" title=""/></a> |
| 69 | <pre class="hey">http://myurl.com</pre> http://myurl.com |
| 70 | </code> |
| 71 | <code> |
| 72 | <pre> |
| 73 | <a href="http://myurl.com" title=""> |
| 74 | <img src="http://myurl.com" title="" /> Check Out My Url |
| 75 | <a class="hey" href="http://myurl.com">myurl.com</a> |
| 76 | <a href="http://myurl.com" title="">http://myurl.com <img src="http://myurl.com" title=""/></a> |
| 77 | </a> |
| 78 | </pre> |
| 79 | </code> |
| 80 | <img src="http://myurl.com" title="" /> |
| 81 | <img src="http://myurl.com" title="">'; |
| 82 | |
| 83 | $testData = array( |
| 84 | 'replaced' => 'http://myurl.com', |
| 85 | $html => $html, |
| 86 | ); |
| 87 | |
| 88 | foreach ($testData as $expected => $data) { |
| 89 | $p = new \Embera\HtmlProcessor(array('a', 'pre', 'img', 'code'), array('http://myurl.com' => 'replaced')); |
| 90 | $result = $p->process($data); |
| 91 | |
| 92 | $this->assertEquals($result, $expected); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | public function testFuckedUpHtmlContent() |
| 97 | { |
| 98 | $testData = array( |
| 99 | '<pre> this dumb html has no ending tag' => '<pre> this shit html has no ending tag', |
| 100 | '<a href="shit"><pre> this shit html is not that great </a></pre>' => '<a href="shit"><pre> this shit html is not that great </a></pre>', |
| 101 | ); |
| 102 | |
| 103 | |
| 104 | foreach ($testData as $expected => $data) { |
| 105 | $p = new \Embera\HtmlProcessor(array('a', 'pre', 'img'), array('shit' => 'dumb')); |
| 106 | $result = $p->process($data); |
| 107 | |
| 108 | $this->assertEquals($result, $expected); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | ?> |
| 114 |