diff --git a/src/Youtube.php b/src/Youtube.php index af537ff..8b9d3f7 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -36,6 +36,14 @@ public function youtubeEmbedCode() . ' allowfullscreen>'; } + public function youtubeChannelUri() + { + return sprintf('https://www.youtube.com/%s/%s', + $this->randomElement(['channel', 'user']), + $this->regexify(sprintf('[a-zA-Z0-9\-]{1,%s}', $this->numberBetween(1, 20))) + ); + } + public function youtubeRandomUri() { switch ($this->numberBetween(1,3)) { diff --git a/tests/Faker/YoutubeTest.php b/tests/Faker/YoutubeTest.php index 1fc4a28..1011703 100644 --- a/tests/Faker/YoutubeTest.php +++ b/tests/Faker/YoutubeTest.php @@ -37,6 +37,11 @@ public function testYoutubeEmbedUri() $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtube\.com\/embed\/)(.+)#', $this->faker->youtubeEmbedUri()); } + public function testYoutubeChannelUri() + { + $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtube\.com\/)(c\/|channel\/|user\/)([a-zA-Z0-9\-]{1,})#', $this->faker->youtubeChannelUri()); + } + public function testYoutubeEmbedCode() { $this->assertRegExp('#