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
TestUrl.php
153 lines
| 1 | <?php |
| 2 | /** |
| 3 | * TestUrl.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 TestUrl extends PHPUnit_Framework_TestCase |
| 14 | { |
| 15 | public function testInvalidPattern() |
| 16 | { |
| 17 | $url = new \Embera\Url('http://www.hablarmierda.net/path/stuff/'); |
| 18 | $url->invalidPattern('\.net/path/(?:[^/]+)/'); |
| 19 | $this->assertEmpty((string) $url); |
| 20 | |
| 21 | $url = new \Embera\Url('http://www.hablarmierda.net'); |
| 22 | $url->invalidPattern('\.net/hi/'); |
| 23 | $this->assertEquals('http://www.hablarmierda.net', (string) $url); |
| 24 | } |
| 25 | |
| 26 | public function testStripQueryString() |
| 27 | { |
| 28 | $url = new \Embera\Url('http://www.hablarmierda.net/path/?hi=why&id=8'); |
| 29 | $url->stripQueryString(); |
| 30 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 31 | |
| 32 | $url = new \Embera\Url('http://www.hablarmierda.net/path?hi=why&id=8'); |
| 33 | $url->stripQueryString(); |
| 34 | $this->assertEquals('http://www.hablarmierda.net/path', (string) $url); |
| 35 | |
| 36 | $url = new \Embera\Url('http://www.hablarmierda.net/path/#hi'); |
| 37 | $url->stripQueryString(); |
| 38 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 39 | |
| 40 | $url = new \Embera\Url('http://www.hablarmierda.net/path/#hi&ho=80'); |
| 41 | $url->stripQueryString(); |
| 42 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 43 | |
| 44 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 45 | $url->stripQueryString(); |
| 46 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 47 | } |
| 48 | |
| 49 | public function testDiscardChanges() |
| 50 | { |
| 51 | $url = new \Embera\Url('http://www.hablarmierda.net/path/?hi=why&id=8'); |
| 52 | $url->stripQueryString(); |
| 53 | $url->stripLastSlash(); |
| 54 | $this->assertEquals('http://www.hablarmierda.net/path', (string) $url); |
| 55 | |
| 56 | $url->discardChanges(); |
| 57 | $this->assertEquals('http://www.hablarmierda.net/path/?hi=why&id=8', (string) $url); |
| 58 | } |
| 59 | |
| 60 | public function testStripLastSlash() |
| 61 | { |
| 62 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 63 | $url->stripLastSlash(); |
| 64 | $this->assertEquals('http://www.hablarmierda.net/path', (string) $url); |
| 65 | |
| 66 | $url = new \Embera\Url('http://www.hablarmierda.net/path////'); |
| 67 | $url->stripLastSlash(); |
| 68 | $this->assertEquals('http://www.hablarmierda.net/path', (string) $url); |
| 69 | |
| 70 | $url = new \Embera\Url('http://www.hablarmierda.net/path'); |
| 71 | $url->stripLastSlash(); |
| 72 | $this->assertEquals('http://www.hablarmierda.net/path', (string) $url); |
| 73 | } |
| 74 | |
| 75 | public function testStripWWW() |
| 76 | { |
| 77 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 78 | $url->stripWWW(); |
| 79 | $this->assertEquals('http://hablarmierda.net/path/', (string) $url); |
| 80 | |
| 81 | $url = new \Embera\Url('https://www.hablarmierda.net/path/'); |
| 82 | $url->stripWWW(); |
| 83 | $this->assertEquals('https://hablarmierda.net/path/', (string) $url); |
| 84 | |
| 85 | $url = new \Embera\Url('http://hablarmierda.www.net/path/'); |
| 86 | $url->stripWWW(); |
| 87 | $this->assertEquals('http://hablarmierda.www.net/path/', (string) $url); |
| 88 | |
| 89 | $url = new \Embera\Url('http://hablarmierda.net/path/'); |
| 90 | $url->stripWWW(); |
| 91 | $this->assertEquals('http://hablarmierda.net/path/', (string) $url); |
| 92 | |
| 93 | $url = new \Embera\Url('http://hablarmierda.net/path/www.'); |
| 94 | $url->stripWWW(); |
| 95 | $this->assertEquals('http://hablarmierda.net/path/www.', (string) $url); |
| 96 | } |
| 97 | |
| 98 | public function testAddWWW() |
| 99 | { |
| 100 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 101 | $url->addWWW(); |
| 102 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 103 | |
| 104 | $url = new \Embera\Url('http://hablarmierda.net/path/'); |
| 105 | $url->addWWW(); |
| 106 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 107 | |
| 108 | $url = new \Embera\Url('https://hablarmierda.net/path/'); |
| 109 | $url->addWWW(); |
| 110 | $this->assertEquals('https://www.hablarmierda.net/path/', (string) $url); |
| 111 | } |
| 112 | |
| 113 | public function testConvertToHttp() |
| 114 | { |
| 115 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 116 | $url->convertToHttp(); |
| 117 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 118 | |
| 119 | $url = new \Embera\Url('https://hablarmierda.net/path/'); |
| 120 | $url->convertToHttp(); |
| 121 | $this->assertEquals('http://hablarmierda.net/path/', (string) $url); |
| 122 | |
| 123 | $url = new \Embera\Url('https://www.hablarmierda.net/path/'); |
| 124 | $url->convertToHttp(); |
| 125 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 126 | } |
| 127 | |
| 128 | public function testConvertToHttps() |
| 129 | { |
| 130 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 131 | $url->convertToHttps(); |
| 132 | $this->assertEquals('https://www.hablarmierda.net/path/', (string) $url); |
| 133 | |
| 134 | $url = new \Embera\Url('https://hablarmierda.net/path/'); |
| 135 | $url->convertToHttps(); |
| 136 | $this->assertEquals('https://hablarmierda.net/path/', (string) $url); |
| 137 | |
| 138 | $url = new \Embera\Url('http://www.hablarmierda.net/path/'); |
| 139 | $url->convertToHttps(); |
| 140 | $this->assertEquals('https://www.hablarmierda.net/path/', (string) $url); |
| 141 | } |
| 142 | |
| 143 | public function testEmbed() |
| 144 | { |
| 145 | $url = new \Embera\Url('embed://www.hablarmierda.net/path/'); |
| 146 | $this->assertEquals('http://www.hablarmierda.net/path/', (string) $url); |
| 147 | |
| 148 | $url = new \Embera\Url('embed://www.hablarmierda.net/path/'); |
| 149 | $url->convertToHttps(); |
| 150 | $this->assertEquals('https://www.hablarmierda.net/path/', (string) $url); |
| 151 | } |
| 152 | } |
| 153 |