File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Test/Unit/Model/Config/Backend Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Config \Model \Config \Backend ;
7
7
8
- use Magento \Framework \Validator \Url as UrlValidator ;
9
8
use Magento \Framework \App \ObjectManager ;
9
+ use Magento \Framework \Validator \Url as UrlValidator ;
10
10
11
11
/**
12
12
* @api
@@ -56,7 +56,7 @@ public function __construct(
56
56
*/
57
57
public function beforeSave ()
58
58
{
59
- $ value = $ this ->getValue ();
59
+ $ value = strtolower ( $ this ->getValue () );
60
60
try {
61
61
if (!$ this ->_validateUnsecure ($ value ) && !$ this ->_validateSecure ($ value )) {
62
62
$ this ->_validateFullyQualifiedUrl ($ value );
@@ -68,6 +68,7 @@ public function beforeSave()
68
68
$ error = new \Magento \Framework \Exception \LocalizedException ($ msg , $ e );
69
69
throw $ error ;
70
70
}
71
+ $ this ->setValue ($ value );
71
72
}
72
73
73
74
/**
@@ -232,6 +233,7 @@ public function afterSave()
232
233
* Get URL Validator
233
234
*
234
235
* @deprecated 100.1.12
236
+ * @see Nothing
235
237
* @return UrlValidator
236
238
*/
237
239
private function getUrlValidator ()
Original file line number Diff line number Diff line change @@ -61,4 +61,30 @@ public function testSaveMergedJsCssMustBeCleaned()
61
61
$ model ->setValue ('http://example.com/ ' )->setPath (Store::XML_PATH_UNSECURE_BASE_URL );
62
62
$ model ->afterSave ();
63
63
}
64
+
65
+ /**
66
+ * @dataProvider beforeSaveDataProvider
67
+ * @param string|null $value
68
+ * @param string|bool $expectedValue false if exception to be thrown
69
+ * @return void
70
+ */
71
+ public function testBeforeSaveConvertLowerCase ($ value , $ expectedValue )
72
+ {
73
+ $ model = (new ObjectManager ($ this ))->getObject (Baseurl::class);
74
+ $ model ->setValue ($ value );
75
+ $ model ->beforeSave ();
76
+ $ this ->assertEquals ($ expectedValue , $ model ->getValue ());
77
+ }
78
+
79
+ /**
80
+ * @return array
81
+ */
82
+ public function beforeSaveDataProvider ()
83
+ {
84
+ return [
85
+ ['https://Example1.com/ ' , 'https://example1.com/ ' ],
86
+ ['https://EXAMPLE2.COM/ ' , 'https://example2.com/ ' ],
87
+ ['HTtpS://ExamPLe3.COM/ ' , 'https://example3.com/ ' ],
88
+ ];
89
+ }
64
90
}
You can’t perform that action at this time.
0 commit comments