From 5234fd00df0b83b3c4c183e3a41bb8962e20e251 Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:12:07 +0100 Subject: [PATCH 1/7] Added test for youtube share url --- tests/YoutubeTest.php | 91 ++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index 786f858c..3520bfd8 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -4,50 +4,61 @@ class YoutubeTest extends AbstractTestCase { + + const $expectedVideo = [ + 'title' => 'Noisy kittens waiting for dinner!', + 'imageWidth' => 480, + 'imageHeight' => 360, + 'type' => 'video', + 'authorName' => 'smshdchrb', + 'authorUrl' => 'https://www.youtube.com/user/smshdchrb', + 'providerName' => 'YouTube', + 'providerUrl' => 'https://www.youtube.com/', + 'tags' => [ + 'kittens', + 'cats', + 'hungry', + 'cat', + 'baby', + 'eight', + 'weeks', + 'old', + 'noisy', + 'meow', + 'funny', + 'kitties', + 'feline', + 'dinner', + 'excited', + 'loud', + 'cute', + 'pet', + 'food', + 'time', + 'felix', + 'kitty', + 'catz', + 'lolcat', + 'kitten', + 'talking', + 'adorable', + 'climbing' + ], + ]; + public function testOne() { $this->assertEmbed( 'http://www.youtube.com/watch?v=eiHXASgRTcA', - [ - 'title' => 'Noisy kittens waiting for dinner!', - 'imageWidth' => 480, - 'imageHeight' => 360, - 'type' => 'video', - 'authorName' => 'smshdchrb', - 'authorUrl' => 'https://www.youtube.com/user/smshdchrb', - 'providerName' => 'YouTube', - 'providerUrl' => 'https://www.youtube.com/', - 'tags' => [ - 'kittens', - 'cats', - 'hungry', - 'cat', - 'baby', - 'eight', - 'weeks', - 'old', - 'noisy', - 'meow', - 'funny', - 'kitties', - 'feline', - 'dinner', - 'excited', - 'loud', - 'cute', - 'pet', - 'food', - 'time', - 'felix', - 'kitty', - 'catz', - 'lolcat', - 'kitten', - 'talking', - 'adorable', - 'climbing' - ], - ] + $expectedVideo + ); + } + + public function testShareUrl() + { + $this->assertEmbed( + 'http://www.youtu.be/eiHXASgRTcA', + $expectedVideo ); } From a7de0ebfc6196ddbc80e0de16e705d72cb68082a Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:13:04 +0100 Subject: [PATCH 2/7] Allow YouTube share url --- src/Providers/OEmbed/Youtube.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/OEmbed/Youtube.php b/src/Providers/OEmbed/Youtube.php index 0f312910..ec337a57 100644 --- a/src/Providers/OEmbed/Youtube.php +++ b/src/Providers/OEmbed/Youtube.php @@ -4,6 +4,6 @@ class Youtube extends EndPoint implements EndPointInterface { - protected static $pattern = '*youtube.*'; + protected static $pattern = '*youtu\.?be.*'; protected static $endPoint = 'http://www.youtube.com/oembed'; } From 2206af7f6c7f3d18a80646596e5e97dff0b4e56e Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:15:57 +0100 Subject: [PATCH 3/7] Fixed constant --- tests/YoutubeTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index 3520bfd8..e1c4e2d8 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -5,7 +5,7 @@ class YoutubeTest extends AbstractTestCase { - const $expectedVideo = [ + const EXPECTED_VIDEO_INFO = [ 'title' => 'Noisy kittens waiting for dinner!', 'imageWidth' => 480, 'imageHeight' => 360, @@ -50,7 +50,7 @@ public function testOne() { $this->assertEmbed( 'http://www.youtube.com/watch?v=eiHXASgRTcA', - $expectedVideo + self::EXPECTED_VIDEO_INFO ); } @@ -58,7 +58,7 @@ public function testShareUrl() { $this->assertEmbed( 'http://www.youtu.be/eiHXASgRTcA', - $expectedVideo + self::EXPECTED_VIDEO_INFO ); } From 010247b7f66e8a9425e6a4dd13c1aae56911ea0c Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:20:55 +0100 Subject: [PATCH 4/7] Remove const --- tests/YoutubeTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index e1c4e2d8..724b49b8 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -5,7 +5,7 @@ class YoutubeTest extends AbstractTestCase { - const EXPECTED_VIDEO_INFO = [ + private $expectedVideoInfo = [ 'title' => 'Noisy kittens waiting for dinner!', 'imageWidth' => 480, 'imageHeight' => 360, @@ -50,7 +50,7 @@ public function testOne() { $this->assertEmbed( 'http://www.youtube.com/watch?v=eiHXASgRTcA', - self::EXPECTED_VIDEO_INFO + self::$expectedVideoInfo ); } @@ -58,7 +58,7 @@ public function testShareUrl() { $this->assertEmbed( 'http://www.youtu.be/eiHXASgRTcA', - self::EXPECTED_VIDEO_INFO + self::$expectedVideoInfo ); } From caff108ccea5b1292831ebe117b2a0dcf3ee8325 Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:40:53 +0100 Subject: [PATCH 5/7] Added missing static modifier --- tests/YoutubeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index 724b49b8..faf01388 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -5,7 +5,7 @@ class YoutubeTest extends AbstractTestCase { - private $expectedVideoInfo = [ + static private $expectedVideoInfo = [ 'title' => 'Noisy kittens waiting for dinner!', 'imageWidth' => 480, 'imageHeight' => 360, From f355f09aa86a0b14773d37d3558cb0d468f0d849 Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 11:48:26 +0100 Subject: [PATCH 6/7] Fix share url: remove www --- tests/YoutubeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/YoutubeTest.php b/tests/YoutubeTest.php index faf01388..8b158561 100644 --- a/tests/YoutubeTest.php +++ b/tests/YoutubeTest.php @@ -57,7 +57,7 @@ public function testOne() public function testShareUrl() { $this->assertEmbed( - 'http://www.youtu.be/eiHXASgRTcA', + 'http://youtu.be/eiHXASgRTcA', self::$expectedVideoInfo ); } From 4ef2c13f5660e0730cfd25d07d6a9631a942c09e Mon Sep 17 00:00:00 2001 From: kmcs Date: Thu, 7 Mar 2019 14:28:52 +0100 Subject: [PATCH 7/7] Changes as suggested --- src/Providers/OEmbed/Youtube.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/OEmbed/Youtube.php b/src/Providers/OEmbed/Youtube.php index ec337a57..7f3fd864 100644 --- a/src/Providers/OEmbed/Youtube.php +++ b/src/Providers/OEmbed/Youtube.php @@ -4,6 +4,6 @@ class Youtube extends EndPoint implements EndPointInterface { - protected static $pattern = '*youtu\.?be.*'; + protected static $pattern = ['*youtube.*', '*youtu\.be.*']; protected static $endPoint = 'http://www.youtube.com/oembed'; }