@@ -11,13 +11,13 @@ class AbstractShopTest extends TestCase
11
11
{
12
12
public function testMethods (): void
13
13
{
14
- $ shop = new TestShop ('1 ' , '2 ' , '3 ' );
14
+ $ shop = new TestShop ('1 ' , 'https://test-url.com/ ' , '3 ' );
15
15
$ shop ->setShopSecret ('2 ' );
16
- $ shop ->setShopUrl ('3 ' );
16
+ $ shop ->setShopUrl ('https://test-url.com/ ' );
17
17
18
18
static ::assertSame ('1 ' , $ shop ->getShopId ());
19
19
static ::assertSame ('2 ' , $ shop ->getShopSecret ());
20
- static ::assertSame ('3 ' , $ shop ->getShopUrl ());
20
+ static ::assertSame ('https://test-url.com ' , $ shop ->getShopUrl ());
21
21
static ::assertFalse ($ shop ->isShopActive ());
22
22
$ shop ->setShopActive (true );
23
23
static ::assertTrue ($ shop ->isShopActive ());
@@ -26,6 +26,64 @@ public function testMethods(): void
26
26
static ::assertSame ('a ' , $ shop ->getShopClientId ());
27
27
static ::assertSame ('b ' , $ shop ->getShopClientSecret ());
28
28
}
29
+
30
+ #[DataProvider('shopValidUrlDataProvider ' )]
31
+ public function testInvalidUrl (
32
+ string $ shopUrl ,
33
+ string $ expectedUrl
34
+ ): void {
35
+ $ shop = new TestShop ('shopId ' , $ shopUrl , 'shopSecret ' );
36
+ static ::assertSame ($ expectedUrl , $ shop ->getShopUrl ());
37
+ }
38
+
39
+ public static function shopValidUrlDataProvider (): \Generator
40
+ {
41
+ yield 'Valid URL without trailing slash ' => [
42
+ 'shopUrl ' => 'https://test.com ' ,
43
+ 'expectedUrl ' => 'https://test.com ' ,
44
+ ];
45
+
46
+ yield 'Valid URL with trailing slash ' => [
47
+ 'shopUrl ' => 'https://test.com/ ' ,
48
+ 'expectedUrl ' => 'https://test.com ' ,
49
+ ];
50
+
51
+ yield 'Invalid URL with trailing slash ' => [
52
+ 'shopUrl ' => 'https://test.com/test/ ' ,
53
+ 'expectedUrl ' => 'https://test.com/test ' ,
54
+ ];
55
+
56
+ yield 'Invalid URL with double slashes ' => [
57
+ 'shopUrl ' => 'https://test.com//test ' ,
58
+ 'expectedUrl ' => 'https://test.com/test ' ,
59
+ ];
60
+
61
+
62
+ yield 'Invalid URL with 2 slashes and trailing slash ' => [
63
+ 'shopUrl ' => 'https://test.com//test/ ' ,
64
+ 'expectedUrl ' => 'https://test.com/test ' ,
65
+ ];
66
+
67
+ yield 'Invalid URL with 3 slashes and trailing slash ' => [
68
+ 'shopUrl ' => 'https://test.com///test/ ' ,
69
+ 'expectedUrl ' => 'https://test.com/test ' ,
70
+ ];
71
+
72
+ yield 'Invalid URL with multiple slashes ' => [
73
+ 'shopUrl ' => 'https://test.com///test/test1//test2 ' ,
74
+ 'expectedUrl ' => 'https://test.com/test/test1/test2 ' ,
75
+ ];
76
+
77
+ yield 'Invalid URL with multiple slashes and trailing slash ' => [
78
+ 'shopUrl ' => 'https://test.com///test/test1//test2/ ' ,
79
+ 'expectedUrl ' => 'https://test.com/test/test1/test2 ' ,
80
+ ];
81
+
82
+ yield 'Invalid URL with multiple slashes and multplie trailing slash ' => [
83
+ 'shopUrl ' => 'https://test.com///test/test1//test2// ' ,
84
+ 'expectedUrl ' => 'https://test.com/test/test1/test2 ' ,
85
+ ];
86
+ }
29
87
}
30
88
31
89
class TestShop extends AbstractShop
0 commit comments