10
10
use Magento \Backend \Model \View \Result \RedirectFactory ;
11
11
use Magento \CurrencySymbol \Controller \Adminhtml \System \Currencysymbol \Save ;
12
12
use Magento \CurrencySymbol \Model \System \Currencysymbol ;
13
+ use Magento \CurrencySymbol \Model \System \CurrencysymbolFactory ;
13
14
use Magento \Framework \App \RequestInterface ;
14
15
use Magento \Framework \App \Response \RedirectInterface ;
15
16
use Magento \Framework \App \ResponseInterface ;
16
17
use Magento \Framework \Filter \FilterManager ;
17
18
use Magento \Framework \Message \ManagerInterface ;
18
- use Magento \Framework \ObjectManagerInterface ;
19
19
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
20
20
use PHPUnit \Framework \TestCase ;
21
21
use PHPUnit \Framework \MockObject \MockObject ;
@@ -45,16 +45,6 @@ class SaveTest extends TestCase
45
45
*/
46
46
protected $ responseMock ;
47
47
48
- /**
49
- * @var ObjectManagerInterface|MockObject
50
- */
51
- protected $ objectManagerMock ;
52
-
53
- /**
54
- * @var Currencysymbol|MockObject
55
- */
56
- protected $ currencySymbolMock ;
57
-
58
48
/**
59
49
* @var ManagerInterface|MockObject
60
50
*/
@@ -73,7 +63,12 @@ class SaveTest extends TestCase
73
63
/**
74
64
* @var FilterManager|MockObject
75
65
*/
76
- protected $ filterManagerMock ;
66
+ private $ filterManager ;
67
+
68
+ /**
69
+ * @var CurrencysymbolFactory|MockObject
70
+ */
71
+ private $ currencySymbolFactory ;
77
72
78
73
/**
79
74
* @inheritdoc
@@ -88,25 +83,25 @@ protected function setUp()
88
83
ResponseInterface::class,
89
84
['setRedirect ' , 'sendResponse ' ]
90
85
);
91
- $ this ->currencySymbolMock = $ this ->createMock (Currencysymbol::class);
92
- $ this ->filterManagerMock = $ this ->createPartialMock (
86
+ $ this ->messageManagerMock = $ this ->createMock (ManagerInterface::class);
87
+ $ this ->resultRedirectFactory = $ this ->createMock (RedirectFactory::class);
88
+ $ this ->filterManager = $ this ->createPartialMock (
93
89
FilterManager::class,
94
90
['stripTags ' ]
95
91
);
96
- $ this ->objectManagerMock = $ this ->createMock (ObjectManagerInterface::class);
97
- $ this ->messageManagerMock = $ this ->createMock (ManagerInterface::class);
98
- $ this ->resultRedirectFactory = $ this ->createMock (RedirectFactory::class);
92
+ $ this ->currencySymbolFactory = $ this ->createMock (CurrencysymbolFactory::class);
99
93
100
94
$ this ->action = $ objectManager ->getObject (
101
95
Save::class,
102
96
[
103
97
'request ' => $ this ->requestMock ,
104
98
'response ' => $ this ->responseMock ,
105
- 'objectManager ' => $ this ->objectManagerMock ,
106
99
'redirect ' => $ this ->redirectMock ,
107
100
'helper ' => $ this ->helperMock ,
108
101
'messageManager ' => $ this ->messageManagerMock ,
109
102
'resultRedirectFactory ' => $ this ->resultRedirectFactory ,
103
+ 'filterManager ' => $ this ->filterManager ,
104
+ 'currencySymbolFactory ' => $ this ->currencySymbolFactory ,
110
105
]
111
106
);
112
107
}
@@ -124,23 +119,14 @@ public function testExecute()
124
119
->with ('custom_currency_symbol ' )
125
120
->willReturn ($ symbolsDataArray );
126
121
127
- $ this ->currencySymbolMock ->expects ($ this ->once ())->method ('setCurrencySymbolsData ' )->with ($ symbolsDataArray );
128
-
129
- $ this ->filterManagerMock ->expects ($ this ->once ())
122
+ $ currencySymbol = $ this ->createMock (Currencysymbol::class);
123
+ $ currencySymbol ->expects ($ this ->once ())->method ('setCurrencySymbolsData ' )->with ($ symbolsDataArray );
124
+ $ this ->currencySymbolFactory ->method ('create ' )->willReturn ($ currencySymbol );
125
+ $ this ->filterManager ->expects ($ this ->once ())
130
126
->method ('stripTags ' )
131
127
->with ($ firstElement )
132
128
->willReturn ($ firstElement );
133
129
134
- $ this ->objectManagerMock ->expects ($ this ->once ())
135
- ->method ('create ' )
136
- ->with (Currencysymbol::class)
137
- ->willReturn ($ this ->currencySymbolMock );
138
-
139
- $ this ->objectManagerMock ->expects ($ this ->once ())
140
- ->method ('get ' )
141
- ->with (FilterManager::class)
142
- ->willReturn ($ this ->filterManagerMock );
143
-
144
130
$ this ->messageManagerMock ->expects ($ this ->once ())
145
131
->method ('addSuccessMessage ' )
146
132
->with (__ ('You applied the custom currency symbols. ' ));
0 commit comments