PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 1.4.2
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v1.4.2
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / library / ostraining / embera / Tests / TestHttpRequest.php
embedpress / library / ostraining / embera / Tests Last commit date
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
TestHttpRequest.php
170 lines
1 <?php
2 /**
3 * TestHttpRequest.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 TestHttpRequest extends PHPUnit_Framework_TestCase
14 {
15 /**
16 * This needs more execution time ..
17 * @large
18 */
19 public function testInvalidUrl()
20 {
21 $this->setExpectedException('Exception');
22
23 $http = new \Embera\HttpRequest();
24 $http->fetch('this is an invalid url');
25 }
26
27 /**
28 * This needs more execution time ..
29 * @large
30 */
31 public function testInvalidUrl2()
32 {
33 $this->setExpectedException('Exception');
34
35 if (!ini_get('allow_url_fopen'))
36 {
37 $this->markTestIncomplete('Could not test file_get_contents wrapper, allow_url_fopen is closed');
38 return ;
39 }
40
41 $http = new \Embera\HttpRequest(array('prefer_curl' => false));
42 $http->fetch('this is an invalid url');
43 }
44
45 /**
46 * This needs more execution time ..
47 * @large
48 */
49 public function testFetchCurl()
50 {
51 $http = new \Embera\HttpRequest();
52 $response = $http->fetch('http://httpbin.org/user-agent');
53 $response = json_decode($response, true);
54
55 $this->assertEquals('Mozilla/5.0 PHP/Embera', $response['user-agent']);
56
57 $config = array(
58 'curl' => array(
59 CURLOPT_USERAGENT => 'PHP/Morcilla',
60 )
61 );
62
63 $http = new \Embera\HttpRequest($config);
64 $response = $http->fetch('http://httpbin.org/user-agent');
65 $response = json_decode($response, true);
66
67 $this->assertEquals('PHP/Morcilla', $response['user-agent']);
68
69 $config = array(
70 'curl' => array(
71 CURLOPT_FOLLOWLOCATION => 0,
72 CURLOPT_USERAGENT => 'PHP/Morcilla 2',
73 ),
74 'force_redirects' => true
75 );
76
77 $http = new \Embera\HttpRequest($config);
78 $response = $http->fetch('http://httpbin.org/relative-redirect/2');
79 $response = json_decode($response, true);
80
81 $this->assertEquals('http://httpbin.org/get', $response['url']);
82
83 $response = $http->fetch('http://httpbin.org/redirect-to?url=' . urlencode('http://httpbin.org/user-agent'));
84 $response = json_decode($response, true);
85
86 $this->assertEquals('PHP/Morcilla 2', $response['user-agent']);
87
88 $config = array(
89 'curl' => array(
90 CURLOPT_FOLLOWLOCATION => 1,
91 CURLOPT_USERAGENT => 'PHP/Morcilla 3',
92 ),
93 );
94
95 $http = new \Embera\HttpRequest($config);
96 $response = $http->fetch('http://httpbin.org/relative-redirect/2');
97 $response = json_decode($response, true);
98
99 $this->assertEquals('http://httpbin.org/get', $response['url']);
100
101 $response = $http->fetch('http://httpbin.org/redirect-to?url=' . urlencode('http://httpbin.org/user-agent'));
102 $response = json_decode($response, true);
103
104 $this->assertEquals('PHP/Morcilla 3', $response['user-agent']);
105 }
106
107 /**
108 * This needs more execution time ..
109 * @large
110 */
111 public function testFetchFileGetcontents()
112 {
113 if (!ini_get('allow_url_fopen'))
114 {
115 $this->markTestIncomplete('Could not test file_get_contents wrapper, allow_url_fopen is closed');
116 return ;
117 }
118
119 $config = array(
120 'prefer_curl' => false,
121 'fopen' => array(
122 'user_agent' => 'PHP/FGC Morcilla'
123 )
124 );
125
126 $http = new \Embera\HttpRequest($config);
127 $response = $http->fetch('http://httpbin.org/user-agent');
128 $response = json_decode($response, true);
129
130 $this->assertEquals('PHP/FGC Morcilla', $response['user-agent']);
131
132 $http = new \Embera\HttpRequest($config);
133 $response = $http->fetch('http://httpbin.org/relative-redirect/2');
134 $response = json_decode($response, true);
135
136 $this->assertEquals('http://httpbin.org/get', $response['url']);
137
138 $response = $http->fetch('http://httpbin.org/redirect-to?url=' . urlencode('http://httpbin.org/user-agent'));
139 $response = json_decode($response, true);
140
141 $this->assertEquals('PHP/FGC Morcilla', $response['user-agent']);
142 }
143
144 /**
145 * This needs more execution time ..
146 * @large
147 */
148 public function testOptionsPrecedence()
149 {
150 $config = array(
151 'curl' => array(
152 CURLOPT_USERAGENT => 'PHP/Morcilla 1',
153 )
154 );
155
156 $http = new \Embera\HttpRequest($config);
157 $response = $http->fetch('http://httpbin.org/user-agent', array(
158 'curl' => array(
159 CURLOPT_USERAGENT => 'PHP/Morcilla 2',
160 )
161 ));
162
163 $response = json_decode($response, true);
164
165 $this->assertEquals('PHP/Morcilla 2', $response['user-agent']);
166 }
167 }
168
169 ?>
170