17
17
use Magento \Framework \Registry ;
18
18
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
19
19
use Magento \Framework \View \Asset \MergeService ;
20
+ use Magento \Framework \Validator \Url as UrlValidator ;
21
+ use Magento \Framework \App \ObjectManager as AppObjectManager ;
22
+ use Magento \Framework \ObjectManagerInterface ;
20
23
use Magento \Store \Model \Store ;
21
24
use PHPUnit \Framework \TestCase ;
22
25
@@ -71,6 +74,24 @@ public function testSaveMergedJsCssMustBeCleaned()
71
74
public function testBeforeSaveConvertLowerCase ($ value , $ expectedValue )
72
75
{
73
76
$ model = (new ObjectManager ($ this ))->getObject (Baseurl::class);
77
+
78
+ $ urlValidatorMock = $ this ->getMockBuilder (UrlValidator::class)
79
+ ->disableOriginalConstructor ()
80
+ ->getMock ();
81
+
82
+ $ objectManagerInterface = $ this ->createMock (ObjectManagerInterface::class);
83
+ $ objectManagerInterface ->expects ($ this ->exactly (1 ))
84
+ ->method ('get ' )
85
+ ->with (UrlValidator::class)
86
+ ->willReturn ($ urlValidatorMock );
87
+ AppObjectManager::setInstance ($ objectManagerInterface );
88
+
89
+ $ urlValidatorMock ->expects ($ this ->once ())
90
+ ->method ('isValid ' )
91
+ ->with ($ expectedValue , ['http ' , 'https ' ])
92
+ ->willReturn (true );
93
+
94
+
74
95
$ model ->setValue ($ value );
75
96
$ model ->beforeSave ();
76
97
$ this ->assertEquals ($ expectedValue , $ model ->getValue ());
@@ -79,7 +100,7 @@ public function testBeforeSaveConvertLowerCase($value, $expectedValue)
79
100
/**
80
101
* @return array
81
102
*/
82
- public function beforeSaveDataProvider ()
103
+ public static function beforeSaveDataProvider ()
83
104
{
84
105
return [
85
106
['https://Example1.com/ ' , 'https://example1.com/ ' ],
0 commit comments