Skip to content

Commit 71127b0

Browse files
committed
Added some basic unitests
1 parent 02e9440 commit 71127b0

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: php
2+
php:
3+
- 5.5
4+
- 5.4
5+
script: phpunit tests

tests/EmbedTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
include_once dirname(__DIR__).'/Embed/autoloader.php';
3+
4+
class EmbedTest extends PHPUnit_Framework_TestCase {
5+
private function checkUrl ($url, array $values) {
6+
$info = Embed\Embed::create(new Embed\Url($url));
7+
8+
foreach ($values as $name => $value) {
9+
$this->assertEquals($value, $info->$name);
10+
}
11+
12+
return $info;
13+
}
14+
15+
public function testUrls () {
16+
$this->checkUrl(
17+
'http://www.youtube.com/watch?v=eiHXASgRTcA',
18+
array(
19+
'title' => 'Noisy kittens waiting for dinner!',
20+
'description' => 'Disclaimer - 7 week old fostered kittens waiting on their dinner being prepared. They had been ill with cat flu and were just starting to get their appetite ...',
21+
'image' => 'http://i1.ytimg.com/vi/eiHXASgRTcA/hqdefault.jpg',
22+
'imageWidth' => 480,
23+
'imageHeight' => 360,
24+
'url' => 'http://www.youtube.com/watch?v=eiHXASgRTcA',
25+
'type' => 'video',
26+
'authorName' => 'smshdchrb',
27+
'authorUrl' => 'http://www.youtube.com/user/smshdchrb',
28+
'providerName' => 'YouTube',
29+
'providerUrl' => 'http://www.youtube.com/',
30+
'providerIcon' => 'http://s.ytimg.com/yts/img/favicon-vfldLzJxy.ico',
31+
'width' => 459,
32+
'height' => 344
33+
)
34+
);
35+
36+
$this->checkUrl(
37+
'http://www.politico.com/story/2013/12/presidents-barack-obama-george-w-bush-second-term-101314.html',
38+
array(
39+
'title' => 'Echoes of George W. Bush blues in Barack Obama\'s 2nd term',
40+
'description' => 'As Barack Obama heads into his sixth year in the White House, his aides says they are all too familiar with the notion that his predicament looks similar to George W. Bush’s eight years ago. They’re two presidents dogged by crises largely of their own making, whose welcome with Americans has worn thin after two marathon elections. One president...',
41+
'image' => 'http://images.politico.com/global/2013/12/18/131218_george_w_bush_barack_obama_ap_605.jpg',
42+
'imageWidth' => 605,
43+
'imageHeight' => 328,
44+
'url' => 'http://www.politico.com/story/2013/12/presidents-barack-obama-george-w-bush-second-term-101314.html',
45+
'type' => 'link',
46+
'providerName' => 'POLITICO',
47+
'providerUrl' => 'http://politico.com',
48+
'providerIcon' => 'http://www.politico.com/favicon.ico'
49+
)
50+
);
51+
52+
$this->checkUrl(
53+
'http://www.usatoday.com/story/tech/2013/07/19/microsoft-stock-plummets-12/2569413/',
54+
array(
55+
'title' => 'Microsoft stock plummets 11%',
56+
'description' => 'Investors grow skittish over PC prospects.',
57+
'image' => 'http://www.gannett-cdn.com/-mm-/fe06d222bdd27d15d6ac2b2c11dd7a17f46ceda0/c=141-0-3330-2406&r=x117&c=155x114/local/-/media/USATODAY/GenericImages/2013/07/18/1374181578000-B01-MONEYLINE-BALLMER-12-56733869.JPG',
58+
'imageWidth' => 155,
59+
'imageHeight' => 114,
60+
'url' => 'http://www.usatoday.com/story/tech/2013/07/19/microsoft-stock-plummets-12/2569413/',
61+
'type' => 'link',
62+
'providerName' => 'usatoday',
63+
'providerUrl' => 'http://usatoday.com',
64+
'providerIcon' => 'http://www.gannett-cdn.com/sites/usatoday/images/favicon.png'
65+
)
66+
);
67+
68+
$this->checkUrl(
69+
'http://www.dailymotion.com/video/xy0wd_chats-paresseux',
70+
array(
71+
'title' => 'Chats paresseux',
72+
'description' => 'Regarder la vidéo «Chats paresseux» envoyée par jeanbamin sur Dailymotion.',
73+
'image' => 'http://s1.dmcdn.net/Ay0o/x240-kWu.jpg',
74+
'imageWidth' => 320,
75+
'imageHeight' => 240,
76+
'url' => 'http://www.dailymotion.com/video/xy0wd_chats-paresseux_animals',
77+
'type' => 'video',
78+
'providerName' => 'Dailymotion',
79+
'providerUrl' => 'http://www.dailymotion.com',
80+
'providerIcon' => 'http://static1.dmcdn.net/images/apple-touch-icon.png.vcbf86c6fe83fbbe19'
81+
)
82+
);
83+
}
84+
}

0 commit comments

Comments
 (0)