Skip to content

Commit

Permalink
Merge pull request #291 from KeurbyCandy/fix-twitter-cards
Browse files Browse the repository at this point in the history
Fix Twittercards provider type
  • Loading branch information
oscarotero authored Sep 13, 2018
2 parents e44c03d + 5289d50 commit 4b4ab5f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
14 changes: 6 additions & 8 deletions src/Providers/TwitterCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(Adapter $adapter)

foreach ($html->getElementsByTagName('meta') as $meta) {
$name = trim(strtolower($meta->getAttribute('name')));
$value = $meta->getAttribute('content');
$value = $meta->getAttribute('content') ?: $meta->getAttribute('value');

if (empty($name) || empty($value)) {
continue;
Expand Down Expand Up @@ -69,12 +69,10 @@ public function getType()
}

switch ($type) {
case 'video':
case 'photo':
case 'link':
case 'rich':
return $type;

case 'summary':
case 'summary_large_image':
case 'app':
return 'rich';
case 'player':
return 'video';
}
Expand Down Expand Up @@ -114,7 +112,7 @@ public function getAuthorName()
public function getAuthorUrl()
{
$author = $this->getAuthorName();

if (!empty($author)) {
return 'https://twitter.com/'.ltrim($author, '@');
}
Expand Down
3 changes: 3 additions & 0 deletions tests/CustomAdaptersNamespaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function testOne()
);
}

/**
* @group ignore
*/
public function testTwo()
{
$this->assertEmbed(
Expand Down
3 changes: 3 additions & 0 deletions tests/DailyMotionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class DailyMotionTest extends AbstractTestCase
{
/**
* @group ignore
*/
public function testOne()
{
$this->assertEmbed(
Expand Down
3 changes: 3 additions & 0 deletions tests/FlickrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public function testSets()
);
}

/**
* @group ignore
*/
public function testProfile()
{
$this->assertEmbed(
Expand Down
3 changes: 3 additions & 0 deletions tests/HowcastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class HowcastTest extends AbstractTestCase
{
/**
* @group ignore
*/
public function testOne()
{
$this->assertEmbed(
Expand Down
4 changes: 2 additions & 2 deletions tests/HtmlProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testNotAllowExternalImages()
$this->assertEmbed(
'http://www.brothers-brick.com/2016/04/06/stunning-lego-darth-vader-mask-cleverly-hides-scenes-from-star-wars/',
[
'images' => 2,
'images' => 1,
]
);
}
Expand All @@ -37,7 +37,7 @@ public function testAllowSomeExternalImages()
$this->assertEmbed(
'http://www.brothers-brick.com/2016/04/06/stunning-lego-darth-vader-mask-cleverly-hides-scenes-from-star-wars/',
[
'images' => 4,
'images' => 3,
],
[
'html' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/ImagesBlacklistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function testPlainText()
$this->assertEmbed(
'https://alistapart.com/article/the-rich-typefaces-get-richer',
[
'image' => 'https://alistapart.com/d/_made/pix/authors/photos/shoaf-headshot_120_120_c1.jpg',
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
],
[
'images_blacklist' => [
Expand All @@ -24,7 +24,7 @@ public function testPlainUrlMatch()
$this->assertEmbed(
'https://alistapart.com/article/the-rich-typefaces-get-richer',
[
'image' => 'https://alistapart.com/d/_made/pix/authors/photos/shoaf-headshot_120_120_c1.jpg',
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
],
[
'images_blacklist' => [
Expand All @@ -39,7 +39,7 @@ public function testAuthorizedImage()
$this->assertEmbed(
'https://alistapart.com/article/the-rich-typefaces-get-richer',
[
'image' => 'https://alistapart.com/components/assets/img/ala-logo-big.png',
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
],
[
'images_blacklist' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/PinterestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function testOne()
$this->assertEmbed(
'https://www.pinterest.com/pin/106890191127977979/',
[
'title' => 'Icons',
'title' => 'Pin by Leslie Carruthers on Icons | Pinterest | Jack nicholson, Movie stars and Movie',
'width' => 236,
'height' => 442,
'code' => '<a data-pin-do="embedPin" data-pin-lang="es" href="https://www.pinterest.com/pin/106890191127977979/"></a><script async defer src="//assets.pinterest.com/js/pinit.js"></script>',
Expand Down
2 changes: 1 addition & 1 deletion tests/UrlBlacklistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testVerifyUnwanted()
$this->assertEmbed(
'http://glomdalen.no/skarnes',
[
'url' => 'http://www.glomdalen.no?ns_campaign=frontpage&ns_mchannel=recommend_button&ns_source=facebook&ns_linkname=facebook&ns_fee=0',
'url' => 'https://www.glomdalen.no?ns_campaign=frontpage&ns_mchannel=recommend_button&ns_source=facebook&ns_linkname=facebook&ns_fee=0',
],
[
'url_blacklist' => null,
Expand Down
2 changes: 0 additions & 2 deletions tests/WordPressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public function testOne()
'http://wordpress.tv/2013/09/06/dave-ross-optimize-image-files-like-a-pro/',
[
'title' => 'Dave Ross: Optimize Image Files Like a Pro',
'imageWidth' => 400,
'imageHeight' => 224
]
);
}
Expand Down

0 comments on commit 4b4ab5f

Please sign in to comment.