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 / TestEmbera.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
TestEmbera.php
242 lines
1 <?php
2 /**
3 * TestEmbera.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 TestEmbera extends PHPUnit_Framework_TestCase
14 {
15 public function testInvalidAutoEmbedInput()
16 {
17 $input = array('http://www.youtube.com/watch?v=GP18O6gSWSw&feature=share&list=PL4EF7BAD98F9812B6');
18 $embera = new \Embera\Embera();
19
20 $this->assertEquals($input, $embera->autoEmbed($input));
21 $this->assertTrue($embera->hasErrors());
22 $this->assertTrue(is_string($embera->getLastError()));
23 $this->assertCount(1, $embera->getErrors());
24 }
25
26 public function testInvalidAutoEmbedInput2()
27 {
28 $input = null;
29 $embera = new \Embera\Embera();
30
31 $this->assertEquals($input, $embera->autoEmbed($input));
32 $this->assertTrue(is_string($embera->getLastError()));
33 $this->assertTrue($embera->hasErrors());
34 $this->assertCount(1, $embera->getErrors());
35 }
36
37 public function testAutoEmbedwithoutKnownServices()
38 {
39 $input = 'hola este texto debería seguir igual.';
40 $embera = new \Embera\Embera();
41
42 $this->assertEquals($input, $embera->autoEmbed($input));
43 }
44
45 public function testAutoEmbedwithoutKnownServices2()
46 {
47 $input = 'hola este texto debería seguir igual. http://www.google.com ';
48 $embera = new \Embera\Embera();
49
50 $this->assertEquals($input, $embera->autoEmbed($input));
51 }
52
53 public function testFakeUrlInspection()
54 {
55 $validUrls = array('http://www.youtube.com/watch?v=MpVHQnIvTXo',
56 'http://youtu.be/fSUK4WgQ3vk',
57 'http://www.youtube.com/watch?v=T3O1nffTG-k');
58
59 $embera = new \Embera\Embera(array('oembed' => false));
60 $result = $embera->getUrlInfo($validUrls);
61
62 $this->assertCount(count($validUrls), $result);
63 }
64
65 public function testFakeAutoEmbed()
66 {
67 $text = 'Hey Checkout this video http://www.youtube.com/watch?v=MpVHQnIvTXo, Its just great';
68 $embera = new \Embera\Embera(array('oembed' => false));
69 $result = $embera->autoEmbed($text);
70
71 $this->assertContains('<iframe', $result);
72 $this->assertEmpty($embera->getLastError());
73 }
74
75 public function testCustomProvider()
76 {
77 $oembed = new MockOembed(new MockHttpRequest());
78 $customParams = array('apikey' => 'myapikey');
79 $urls = array(
80 'http://customservice.com/9879837498',
81 'http://host.com/stuff/yes',
82 'http://customservice.com/hi',
83 'http://www.customservice.com/98756478',
84 'http://customservice.com/9879837498/'
85 );
86
87 $p = new \Embera\Providers(array('oembed' => true), $oembed);
88 $p->addProvider('www.customservice.com', 'CustomService', $customParams);
89
90 $this->assertCount(3, $p->getAll($urls));
91
92 $all = $p->getAll($urls);
93 foreach ($all as $s) {
94 $params = array_filter($s->getParams());
95 $this->assertEquals($params, $customParams);
96 }
97 }
98
99 public function testCustomProvider2()
100 {
101 $urls = array(
102 'http://customservice.com/9879837498',
103 'http://host.com/stuff/yes',
104 'http://customservice.com/hi',
105 'http://www.customservice.com/98756478',
106 'http://customservice.com/9879837498/'
107 );
108
109 $embera = new \Embera\Embera();
110 $embera->addProvider('www.customservice.com', 'CustomService', array());
111
112 $reflection = new ReflectionClass('\Embera\Embera');
113 $method = $reflection->getMethod('getProviders');
114 $method->setAccessible(true);
115
116 $providers = $method->invoke($embera, $urls);
117 $this->assertCount(3, $providers);
118 }
119
120 public function testUrlString()
121 {
122 $validUrls = 'Hey what up! http://www.youtube.com/watch?v=MpVHQnIvTXo this is great http://youtu.be/fSUK4WgQ3vk';
123
124 $embera = new \Embera\Embera(array('oembed' => false));
125 $result = $embera->getUrlInfo($validUrls);
126 $this->assertCount(2, $result);
127 }
128
129 public function testCustomParams()
130 {
131 $config = array(
132 'custom_params' => array(
133 'Youtube' => array('custom' => 'none'),
134 'vimeO' => array('apikey' => '8987928734234'),
135 'CustomService' => array('align' => 'left')
136 )
137 );
138
139 $embera = new \Embera\Embera($config);
140
141 $reflection = new ReflectionClass('\Embera\Embera');
142 $method = $reflection->getMethod('getProviders');
143 $method->setAccessible(true);
144
145 $providers = $method->invoke($embera, array(
146 'http://customservice.com/12345',
147 'http://stuff.com/unknown',
148 'http://youtu.be/fSUK4WgQ3vk',
149 'http://www.youtube.com/watch?v=MpVHQnIvTXo',
150 'http://vimeo.com/groups/shortfilms/videos/63313811/',
151 'http://www.dailymotion.com/video/xzxtaf_red-bull-400-alic-y-stadlober-ganan-en-eslovenia_sport/',
152 ));
153
154 $this->assertCount(4, $providers);
155
156 foreach($providers as $p)
157 {
158 $class = strtolower(basename(str_replace('\\', '/', get_class($p))));
159 $params = array_filter($p->getParams());
160
161 if ($class == 'youtube')
162 $this->assertEquals($params, $config['custom_params']['Youtube']);
163 else if ($class == 'vimeo')
164 $this->assertEquals($params, $config['custom_params']['vimeO']);
165 else
166 $this->assertTrue(empty($params), 'Param array for ' . $class . ' - ' . print_r($params, true));
167 }
168 }
169
170 public function testDenyService()
171 {
172 $validUrls = array('http://www.youtube.com/watch?v=MpVHQnIvTXo',
173 'http://youtu.be/fSUK4WgQ3vk',
174 'http://vimeo.com/groups/shortfilms/videos/63313811/',
175 'http://www.youtube.com/watch?v=T3O1nffTG-k');
176
177 $embera = new \Embera\Embera(array('oembed' => false, 'deny' => array('Youtube')));
178 $result = $embera->getUrlInfo($validUrls);
179 $this->assertCount(1, $result);
180
181 $embera = new \Embera\Embera(array('oembed' => false, 'deny' => array('youTube')));
182 $result = $embera->getUrlInfo($validUrls);
183 $this->assertCount(1, $result);
184 }
185
186 public function testAllowService()
187 {
188 $validUrls = array('http://www.youtube.com/watch?v=MpVHQnIvTXo',
189 'http://youtu.be/fSUK4WgQ3vk',
190 'http://vimeo.com/groups/shortfilms/videos/63313811/',
191 'http://www.dailymotion.com/video/xzxtaf_red-bull-400-alic-y-stadlober-ganan-en-eslovenia_sport/',
192 'http://www.youtube.com/watch?v=T3O1nffTG-k');
193
194 $embera = new \Embera\Embera(array('oembed' => false, 'allow' => array('Vimeo', 'dailyMotion')));
195 $result = $embera->getUrlInfo($validUrls);
196 $this->assertCount(2, $result);
197
198 $embera = new \Embera\Embera(array('oembed' => false, 'allow' => array('Youtube', 'Dailymotion')));
199 $result = $embera->getUrlInfo($validUrls);
200 $this->assertCount((count($validUrls) - 1), $result);
201 }
202
203 public function testEmbedPrefixService()
204 {
205 $validUrls = array('embed://www.youtube.com/watch?v=MpVHQnIvTXo',
206 'http://youtu.be/fSUK4WgQ3vk',
207 'http://vimeo.com/groups/shortfilms/videos/63313811/',
208 'embed://www.dailymotion.com/video/xzxtaf_red-bull-400-alic-y-stadlober-ganan-en-eslovenia_sport/',
209 'embed://www.youtube.com/watch?v=T3O1nffTG-k');
210
211 $embera = new \Embera\Embera(array('oembed' => false, 'use_embed_prefix' => false));
212 $result = $embera->getUrlInfo($validUrls);
213 $this->assertCount(2, $result);
214
215 $embera = new \Embera\Embera(array('oembed' => false, 'use_embed_prefix' => true));
216 $result = $embera->getUrlInfo($validUrls);
217 $this->assertCount(3, $result);
218 }
219
220 public function testReplaceOrderOnAutoEmbed()
221 {
222 $expected = array(
223 '<iframe width="420" height="315" src="//www.youtube.com/embed/fSUK4WgQ3vk" frameborder="0" allowfullscreen></iframe>',
224 '<iframe width="420" height="315" src="//www.youtube.com/embed/fSUK4WgQ3vkIII" frameborder="0" allowfullscreen></iframe>',
225 '<iframe width="420" height="315" src="//www.youtube.com/embed/fSUK4WgQ3vkII" frameborder="0" allowfullscreen></iframe>'
226 );
227
228 $urls = array(
229 'http://youtu.be/fSUK4WgQ3vk',
230 'http://youtu.be/fSUK4WgQ3vkIII',
231 'http://youtu.be/fSUK4WgQ3vkII'
232 );
233
234 $embera = new \Embera\Embera(array('oembed' => false));
235 $result = $embera->autoEmbed(implode(', ', $urls));
236
237 $this->assertEquals($result, implode(', ', $expected));
238 }
239 }
240
241 ?>
242