Skip to content

Commit 010c6ae

Browse files
committed
improved tests
1 parent e069dc9 commit 010c6ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+444
-423
lines changed

src/Adapters/Google.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Google extends Webpage implements AdapterInterface
1616
public static function check(Request $request)
1717
{
1818
return $request->isValid() && $request->match([
19-
'https://maps.google.*',
20-
'https://www.google.*/maps*',
19+
//'https://maps.google.*',
20+
//'https://www.google.*/maps*',
2121
'https://drive.google.com/file/*/view',
2222
]);
2323
}
@@ -27,13 +27,14 @@ public static function check(Request $request)
2727
*/
2828
public function getCode()
2929
{
30-
$url = $this->request->createUrl();
30+
$url = $this->request->createUrl()
31+
->withDirectoryPosition(3, 'preview')
32+
->withQueryParameters([]);
33+
34+
return Utils::iframe($url);
3135

32-
if ($this->request->getHost() === 'drive.google.com') {
33-
return Utils::iframe($url->withDirectoryPosition(3, 'preview')->withQueryParameters([]));
34-
}
35-
36-
return Utils::iframe($url->withQueryParameter('output', 'embed')->withQueryParameter('s', ''));
36+
//this code of google maps no longer works
37+
//return Utils::iframe($url->withQueryParameter('output', 'embed')->withQueryParameter('s', ''));
3738
}
3839

3940
/**

tests/AnimotoTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2-
class AnimotoTest extends PHPUnit_Framework_TestCase
2+
class AnimotoTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('https://animoto.com/play/JzwsBn5FRVxS0qoqcBP5zA');
77

8-
$this->assertEquals($info->title, 'Juno Groove');
9-
$this->assertEquals($info->width, 640);
10-
$this->assertEquals($info->height, 360);
11-
$this->assertEquals($info->type, 'video');
12-
$this->assertEquals($info->authorName, 'Chris Korhonen');
13-
$this->assertEquals($info->providerName, 'Animoto');
8+
$this->assertString($info->title, 'Juno Groove');
9+
$this->assertString($info->width, 640);
10+
$this->assertString($info->height, 360);
11+
$this->assertString($info->type, 'video');
12+
$this->assertString($info->authorName, 'Chris Korhonen');
13+
$this->assertString($info->providerName, 'Animoto');
1414
}
1515
}

tests/AolTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?php
2-
class AolTest extends PHPUnit_Framework_TestCase
2+
class AolTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('http://on.aol.com/video/whats-next-for-google-in-two-minutes-518288612');
77

8-
$this->assertEquals($info->title, "What's Next for Google in Two Minutes");
9-
$this->assertEquals($info->description, "Wherein we smoosh Google's 2014 developer conference keynote from 2.5+ hours down to just under two minutes.");
10-
$this->assertEquals($info->type, 'video');
8+
$this->assertString($info->title, "What's Next for Google in Two Minutes");
9+
$this->assertString($info->description, "Wherein we smoosh Google's 2014 developer conference keynote from 2.5+ hours down to just under two minutes.");
10+
$this->assertString($info->type, 'video');
1111

1212
/*
1313
Comented because in cli the html returned does not contain the oembed meta
1414
so the test fails. Need to investigate.
1515
16-
$this->assertEquals($info->code, "<iframe width='480' height='401' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen src='http://embed.5min.com/PlayerSeed/?playList=518288612&autoStart=true'></iframe>");
17-
$this->assertEquals($info->width, 480);
18-
$this->assertEquals($info->height, 401);
19-
$this->assertEquals($info->authorName, 'Time.com');
20-
$this->assertEquals($info->providerName, 'on.aol.com');
16+
$this->assertString($info->code, "<iframe width='480' height='401' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen src='http://embed.5min.com/PlayerSeed/?playList=518288612&autoStart=true'></iframe>");
17+
$this->assertString($info->width, 480);
18+
$this->assertString($info->height, 401);
19+
$this->assertString($info->authorName, 'Time.com');
20+
$this->assertString($info->providerName, 'on.aol.com');
2121
*/
2222
}
2323
}

tests/AppTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
2-
class AppTest extends PHPUnit_Framework_TestCase
2+
class AppTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('https://alpha.app.net/chrifpa/post/33532003/photo/1');
77

8-
$this->assertEquals($info->title, "Image_from_Riposte_2014-06-28.jpg");
9-
$this->assertEquals($info->description, 'is what I see in my mind when I hear “there’s now a $foo in javascript”. This [photos.app.net]');
10-
$this->assertEquals($info->width, 533);
11-
$this->assertEquals($info->height, 400);
12-
$this->assertEquals($info->type, 'photo');
13-
$this->assertEquals($info->authorName, '@chrifpa');
14-
$this->assertEquals($info->providerName, 'App.net');
8+
$this->assertString($info->title, "Image_from_Riposte_2014-06-28.jpg");
9+
$this->assertString($info->description, 'is what I see in my mind when I hear “there’s now a $foo in javascript”. This [photos.app.net]');
10+
$this->assertString($info->width, 533);
11+
$this->assertString($info->height, 400);
12+
$this->assertString($info->type, 'photo');
13+
$this->assertString($info->authorName, '@chrifpa');
14+
$this->assertString($info->providerName, 'App.net');
1515
}
1616
}

tests/ArchiveTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
class ArchiveTest extends PHPUnit_Framework_TestCase
2+
class ArchiveTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('https://archive.org/details/dn2015-0220_vid');
77

8-
$this->assertEquals($info->width, 640);
9-
$this->assertEquals($info->height, 480);
10-
$this->assertEquals($info->type, 'video');
11-
$this->assertEquals($info->providerName, 'Internet Archive');
8+
$this->assertString($info->width, 640);
9+
$this->assertString($info->height, 480);
10+
$this->assertString($info->type, 'video');
11+
$this->assertString($info->providerName, 'Internet Archive');
1212
}
1313
}

tests/BambuserTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
2-
class BambuserTest extends PHPUnit_Framework_TestCase
2+
class BambuserTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('http://bambuser.com/v/4740575');
77

8-
$this->assertEquals($info->title, "#OccupyWestminster #SaveILF #London #olsx #ONN");
9-
$this->assertEquals($info->description, 'Broadcast by dancole on Bambuser.com');
10-
$this->assertEquals($info->type, 'video');
11-
$this->assertEquals($info->code, '<object id="bplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240"><embed allowfullscreen="true" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" name="bplayer" src="http://static.bambuser.com/r/player.swf?context=oembed&amp;vid=4740575" width="320" height="240" /><param name="movie" value="http://static.bambuser.com/r/player.swf?context=oembed&amp;vid=4740575" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="wmode" value="transparent" /></object>');
12-
$this->assertEquals($info->width, 320);
13-
$this->assertEquals($info->height, 240);
14-
$this->assertEquals($info->authorName, 'dancole');
15-
$this->assertEquals($info->providerName, 'Bambuser.com');
8+
$this->assertString($info->title, "#OccupyWestminster #SaveILF #London #olsx #ONN");
9+
$this->assertString($info->description, 'Broadcast by dancole on Bambuser.com');
10+
$this->assertString($info->type, 'video');
11+
$this->assertString($info->code, '<object id="bplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240"><embed allowfullscreen="true" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" name="bplayer" src="http://static.bambuser.com/r/player.swf?context=oembed&amp;vid=4740575" width="320" height="240" /><param name="movie" value="http://static.bambuser.com/r/player.swf?context=oembed&amp;vid=4740575" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="wmode" value="transparent" /></object>');
12+
$this->assertString($info->width, 320);
13+
$this->assertString($info->height, 240);
14+
$this->assertString($info->authorName, 'dancole');
15+
$this->assertString($info->providerName, 'Bambuser.com');
1616
}
1717
}

tests/BandcampTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
2-
class BandcampTest extends PHPUnit_Framework_TestCase
2+
class BandcampTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('http://jeanjean.bandcamp.com/track/coquin-l-l-phant');
77

8-
$this->assertEquals($info->title, "Coquin L'éléphant, by Jean Jean");
9-
$this->assertEquals($info->description, 'from the album Symmetry');
10-
$this->assertEquals($info->type, 'video');
11-
$this->assertEquals($info->code, '<iframe src="https://bandcamp.com/EmbeddedPlayer/v=2/track=2592086951/size=large/linkcol=0084B4/notracklist=true/twittercard=true/" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:350;height:467;"></iframe>');
12-
$this->assertEquals($info->width, 400);
13-
$this->assertEquals($info->height, 120);
14-
$this->assertEquals($info->providerName, 'Jean Jean');
8+
$this->assertString($info->title, "Coquin L'éléphant, by Jean Jean");
9+
$this->assertString($info->description, 'from the album Symmetry');
10+
$this->assertString($info->type, 'video');
11+
$this->assertString($info->code, '<iframe src="https://bandcamp.com/EmbeddedPlayer/v=2/track=2592086951/size=large/linkcol=0084B4/notracklist=true/twittercard=true/" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:350;height:467;"></iframe>');
12+
$this->assertString($info->width, 400);
13+
$this->assertString($info->height, 120);
14+
$this->assertString($info->providerName, 'Jean Jean');
1515
}
1616
}

tests/BlipTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2-
class BlipTest extends PHPUnit_Framework_TestCase
2+
class BlipTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('http://blip.tv/indevelopment/iamsorry-6839170');
77

8-
$this->assertEquals($info->title, '#IAMSORRY');
9-
$this->assertEquals($info->imageWidth, 720);
10-
$this->assertEquals($info->imageHeight, 405);
11-
$this->assertEquals($info->type, 'video');
12-
$this->assertEquals($info->providerName, 'Blip');
13-
$this->assertEquals($info->code, '<iframe src="http://blip.tv/play/AYOht2YC.x?p=1" width="1280" height="750" frameborder="0" allowfullscreen></iframe>');
8+
$this->assertString($info->title, '#IAMSORRY');
9+
$this->assertString($info->imageWidth, 720);
10+
$this->assertString($info->imageHeight, 405);
11+
$this->assertString($info->type, 'video');
12+
$this->assertString($info->providerName, 'Blip');
13+
$this->assertString($info->code, '<iframe src="http://blip.tv/play/AYOht2YC.x?p=1" width="1280" height="750" frameborder="0" allowfullscreen></iframe>');
1414
}
1515
}

tests/ChirbitTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
2-
class ChirbitTest extends PHPUnit_Framework_TestCase
2+
class ChirbitTest extends TestCaseBase
33
{
44
public function testOne()
55
{
66
$info = Embed\Embed::create('http://chirb.it/7A9L9B');
77

8-
$this->assertEquals($info->title, 'Chirbit [nvanderklippe] Encana conference call');
9-
$this->assertEquals($info->width, 398);
10-
$this->assertEquals($info->height, 120);
11-
$this->assertEquals($info->type, 'rich');
12-
$this->assertEquals($info->providerName, 'Chirbit');
8+
$this->assertString($info->title, 'Chirbit [nvanderklippe] Encana conference call');
9+
$this->assertString($info->width, 398);
10+
$this->assertString($info->height, 120);
11+
$this->assertString($info->type, 'rich');
12+
$this->assertString($info->providerName, 'Chirbit');
1313
}
1414
}

tests/CodepenTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
2-
class CodepenTest extends PHPUnit_Framework_TestCase
2+
class CodepenTest extends TestCaseBase
33
{
44
public function testAnonymous()
55
{
66
$info = Embed\Embed::create('http://codepen.io/anon/pen/QwPVNW');
77

8-
$this->assertEquals($info->imageWidth, 400);
9-
$this->assertEquals($info->imageHeight, 225);
10-
$this->assertEquals($info->code, '<iframe id="cp_embed_QwPVNW" src="https://codepen.io/anon/embed/QwPVNW?height=300&amp;slug-hash=QwPVNW&amp;default-tab=result&amp;host=http%3A%2F%2Fcodepen.io" scrolling="no" frameborder="0" height="300" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe>');
11-
$this->assertEquals($info->type, 'rich');
8+
$this->assertString($info->imageWidth, 400);
9+
$this->assertString($info->imageHeight, 225);
10+
$this->assertString($info->code, '<iframe id="cp_embed_QwPVNW" src="https://codepen.io/anon/embed/QwPVNW?height=300&amp;slug-hash=QwPVNW&amp;default-tab=result&amp;host=http%3A%2F%2Fcodepen.io" scrolling="no" frameborder="0" height="300" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe>');
11+
$this->assertString($info->type, 'rich');
1212
}
1313

1414
public function testNormal()
1515
{
1616
$info = Embed\Embed::create('http://codepen.io/Zhouzi/pen/JoRazP');
1717

18-
$this->assertEquals($info->title, 'TheaterJS');
19-
$this->assertEquals($info->imageWidth, 384);
20-
$this->assertEquals($info->imageHeight, 225);
21-
$this->assertEquals($info->code, '<iframe id="cp_embed_JoRazP" src="https://codepen.io/Zhouzi/embed/JoRazP?height=300&amp;slug-hash=JoRazP&amp;default-tab=result&amp;host=http%3A%2F%2Fcodepen.io" scrolling="no" frameborder="0" height="300" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe>');
22-
$this->assertEquals($info->type, 'rich');
18+
$this->assertString($info->title, 'TheaterJS');
19+
$this->assertString($info->imageWidth, 384);
20+
$this->assertString($info->imageHeight, 225);
21+
$this->assertString($info->code, '<iframe id="cp_embed_JoRazP" src="https://codepen.io/Zhouzi/embed/JoRazP?height=300&amp;slug-hash=JoRazP&amp;default-tab=result&amp;host=http%3A%2F%2Fcodepen.io" scrolling="no" frameborder="0" height="300" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe>');
22+
$this->assertString($info->type, 'rich');
2323
}
2424
}

0 commit comments

Comments
 (0)