3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace tests \unit \Magento \FunctionalTestFramework \Util \Path ;
7
9
8
- use tests \unit \Util \MagentoTestCase ;
9
- use Magento \FunctionalTestingFramework \Util \Path \UrlFormatter ;
10
10
use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
11
+ use Magento \FunctionalTestingFramework \Util \Path \UrlFormatter ;
12
+ use tests \unit \Util \MagentoTestCase ;
11
13
12
14
class UrlFormatterTest extends MagentoTestCase
13
15
{
14
16
/**
15
- * Test url format
17
+ * Test url format.
16
18
*
17
- * @dataProvider formatDataProvider
18
19
* @param string $path
19
- * @param boolean $withTrailingSeparator
20
- * @param mixed string|boolean $expectedPath
20
+ * @param bool $withTrailingSeparator
21
+ * @param string $expectedPath
22
+ *
21
23
* @return void
22
- * @throws TestFrameworkException
24
+ * @dataProvider formatDataProvider
23
25
*/
24
- public function testFormat ($ path , $ withTrailingSeparator , $ expectedPath )
26
+ public function testFormat (string $ path , bool $ withTrailingSeparator , string $ expectedPath ): void
25
27
{
26
28
$ this ->assertEquals ($ expectedPath , UrlFormatter::format ($ path , $ withTrailingSeparator ));
27
29
}
28
30
29
31
/**
30
- * Test url format with exception
32
+ * Test url format with exception.
31
33
*
32
- * @dataProvider formatExceptionDataProvider
33
34
* @param string $path
34
- * @param boolean $withTrailingSeparator
35
+ * @param bool $withTrailingSeparator
36
+ *
35
37
* @return void
36
- * @throws TestFrameworkException
38
+ * @dataProvider formatExceptionDataProvider
37
39
*/
38
- public function testFormatWithException ($ path , $ withTrailingSeparator )
40
+ public function testFormatWithException (string $ path , bool $ withTrailingSeparator ): void
39
41
{
40
42
$ this ->expectException (TestFrameworkException::class);
41
43
$ this ->expectExceptionMessage ("Invalid url: $ path \n" );
42
44
UrlFormatter::format ($ path , $ withTrailingSeparator );
43
45
}
44
46
45
47
/**
46
- * Data input
48
+ * Data input.
47
49
*
48
50
* @return array
49
51
*/
50
- public function formatDataProvider ()
52
+ public function formatDataProvider (): array
51
53
{
52
54
$ url1 = 'http://magento.local/index.php ' ;
53
55
$ url2 = $ url1 . '/ ' ;
@@ -58,34 +60,38 @@ public function formatDataProvider()
58
60
$ url7 = 'http://127.0.0.1:8200 ' ;
59
61
$ url8 = 'wwøw.goåoøgle.coøm ' ;
60
62
$ url9 = 'http://www.google.com ' ;
63
+
61
64
return [
62
- [$ url1 , null , $ url1 ],
65
+ [$ url1 , false , $ url1 ],
63
66
[$ url1 , false , $ url1 ],
64
67
[$ url1 , true , $ url2 ],
65
- [$ url2 , null , $ url1 ],
68
+ [$ url2 , false , $ url1 ],
66
69
[$ url2 , false , $ url1 ],
67
70
[$ url2 , true , $ url2 ],
68
- [$ url3 , null , $ url3 ],
71
+ [$ url3 , false , $ url3 ],
69
72
[$ url3 , false , $ url3 ],
70
73
[$ url3 , true , $ url4 ],
71
- [$ url4 , null , $ url3 ],
74
+ [$ url4 , false , $ url3 ],
72
75
[$ url4 , false , $ url3 ],
73
76
[$ url4 , true , $ url4 ],
74
77
[$ url5 , true , $ url6 ],
75
78
[$ url7 , false , $ url7 ],
76
79
[$ url8 , false , $ url9 ],
80
+ ['https://magento.local/path? ' , false , 'https://magento.local/path? ' ],
81
+ ['https://magento.local/path# ' , false , 'https://magento.local/path# ' ],
82
+ ['https://magento.local/path?# ' , false , 'https://magento.local/path?# ' ]
77
83
];
78
84
}
79
85
80
86
/**
81
- * Invalid data input
87
+ * Invalid data input.
82
88
*
83
89
* @return array
84
90
*/
85
- public function formatExceptionDataProvider ()
91
+ public function formatExceptionDataProvider (): array
86
92
{
87
93
return [
88
- ['' , null ],
94
+ ['' , false ]
89
95
];
90
96
}
91
97
}
0 commit comments