File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
<phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
3
xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/|version|/phpunit.xsd"
4
- bootstrap =" vendor/autoload.php" >
4
+ bootstrap =" vendor/autoload.php"
5
+ displayDetailsOnTestsThatTriggerWarnings =" true"
6
+ failOnWarning =" true"
7
+ >
5
8
<testsuites >
6
9
<testsuite name =" unit" >
7
10
<directory >tests</directory >
Original file line number Diff line number Diff line change @@ -60,8 +60,12 @@ public static function getYouTubeIdFromUrl(string $url): ?string
60
60
61
61
if ($ query ) {
62
62
parse_str ($ query , $ qs );
63
- if ($ qs ['v ' ] || $ qs ['vi ' ]) {
64
- return $ qs ['v ' ] ?? $ qs ['vi ' ];
63
+
64
+ $ v = $ qs ['v ' ] ?? null ;
65
+ $ vi = $ qs ['vi ' ] ?? null ;
66
+
67
+ if ($ v || $ vi ) {
68
+ return $ v ?? $ vi ;
65
69
}
66
70
}
67
71
Original file line number Diff line number Diff line change @@ -13,4 +13,27 @@ public function testGetVideoTypeFromUrl(): void
13
13
ParsingHelper::getVideoTypeFromUrl ('https://www.youtube.com ' )
14
14
);
15
15
}
16
+
17
+ public function testGetYouTubeIdFromUrl (): void
18
+ {
19
+ $ this ->assertEquals (
20
+ '6xWpo5Dn254 ' ,
21
+ ParsingHelper::getYouTubeIdFromUrl ('https://www.youtube.com/watch?v=6xWpo5Dn254 ' )
22
+ );
23
+
24
+ $ this ->assertEquals (
25
+ '6xWpo5Dn254 ' ,
26
+ ParsingHelper::getYouTubeIdFromUrl ('https://www.youtube.com/watch?vi=6xWpo5Dn254 ' )
27
+ );
28
+
29
+ $ this ->assertEquals (
30
+ '--HXLM8GuxA ' ,
31
+ ParsingHelper::getYouTubeIdFromUrl ('https://youtu.be/--HXLM8GuxA?si=pNahKJLszKr8J00u ' )
32
+ );
33
+
34
+ $ this ->assertEquals (
35
+ '--HXLM8GuxA ' ,
36
+ ParsingHelper::getYouTubeIdFromUrl ('https://youtube.com/watch?v=--HXLM8GuxA ' )
37
+ );
38
+ }
16
39
}
You can’t perform that action at this time.
0 commit comments