├── .travis.yml
├── .gitignore
├── phpunit.xml.dist
├── LICENSE
├── composer.json
├── tests
└── Faker
│ └── YoutubeTest.php
├── src
└── Youtube.php
└── README.md
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - '7.1'
5 | - '7.2'
6 | - '7.3'
7 | - '7.4'
8 | - '8.0'
9 |
10 | before_script:
11 | - composer install --dev
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Composer template
3 | composer.phar
4 | vendor/
5 | clover.xml
6 | phpunit.xml
7 |
8 | # Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
9 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
10 | composer.lock
11 |
12 |
13 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | tests
5 |
6 |
7 |
8 |
9 | ./src
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 | Version 2, December 2004
3 |
4 | Copyright (C) 2004 Sam Hocevar
5 |
6 | Everyone is permitted to copy and distribute verbatim or modified
7 | copies of this license document, and changing it is allowed as long
8 | as the name is changed.
9 |
10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12 |
13 | 0. You just DO WHAT THE FUCK YOU WANT TO.
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aalaap/faker-youtube",
3 | "description": "Faker provider for generating fake YouTube video URLs",
4 | "license": "WTFPL",
5 | "authors": [
6 | {
7 | "name": "Aalaap Ghag",
8 | "email": "aalaap@gmail.com"
9 | }
10 | ],
11 | "keywords": ["faker", "provider", "youtube"],
12 | "require": {
13 | "php": "^7.1 || ^8.0",
14 | "fakerphp/faker": "^1.10"
15 | },
16 | "require-dev": {
17 | "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2"
18 | },
19 | "autoload": {
20 | "psr-4": {
21 | "Faker\\Provider\\": "src/"
22 | }
23 | },
24 | "autoload-dev": {
25 | "psr-4": {
26 | "Faker\\Tests\\Provider\\": "tests/Faker"
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tests/Faker/YoutubeTest.php:
--------------------------------------------------------------------------------
1 | addProvider(new Youtube($faker));
22 | $this->faker = $faker;
23 | }
24 |
25 | public function testYoutubeUri(): void
26 | {
27 | $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtube\.com\/watch\?v=)(.+)#', $this->faker->youtubeUri());
28 | }
29 |
30 | public function testYoutubeShortUri(): void
31 | {
32 | $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtu.be\/)(.+)#', $this->faker->youtubeShortUri());
33 | }
34 |
35 | public function testYoutubeEmbedUri(): void
36 | {
37 | $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtube\.com\/embed\/)(.+)#', $this->faker->youtubeEmbedUri());
38 | }
39 |
40 | public function testYoutubeChannelUri(): void
41 | {
42 | $this->assertRegExp('#(http(s)??\:\/\/)?(www\.)?(youtube\.com\/)(c\/|channel\/|user\/)([a-zA-Z0-9\-]{1,})#', $this->faker->youtubeChannelUri());
43 | }
44 |
45 | public function testYoutubeEmbedCode(): void
46 | {
47 | $this->assertRegExp('#