8
8
9
9
namespace Magento \Csp \Test \Unit \Model \Mode ;
10
10
11
+ use Magento \Csp \Api \Data \ModeConfiguredInterface ;
11
12
use Magento \Csp \Model \Mode \ConfigManager ;
12
- use Magento \Csp \Model \Mode \Data \ModeConfigured ;
13
+ use Magento \Csp \Model \Mode \Data \ModeConfiguredFactory ;
13
14
use Magento \Framework \App \Area ;
14
15
use Magento \Framework \App \Config \ScopeConfigInterface ;
15
16
use Magento \Framework \App \Request \Http ;
@@ -51,6 +52,16 @@ class ConfigManagerTest extends TestCase
51
52
*/
52
53
private $ requestMock ;
53
54
55
+ /**
56
+ * @var ModeConfiguredFactory
57
+ */
58
+ private $ modeConfiguredFactoryMock ;
59
+
60
+ /**
61
+ * @var ModeConfiguredInterface
62
+ */
63
+ private $ modeConfiguredInterfaceMock ;
64
+
54
65
/**
55
66
* Set Up
56
67
*/
@@ -62,6 +73,8 @@ protected function setUp(): void
62
73
$ this ->storeMock = $ this ->createMock (Store::class);
63
74
$ this ->stateMock = $ this ->createMock (State::class);
64
75
$ this ->requestMock = $ this ->createMock (Http::class);
76
+ $ this ->modeConfiguredFactoryMock = $ this ->createPartialMock (ModeConfiguredFactory::class, ['create ' ]);
77
+ $ this ->modeConfiguredInterfaceMock = $ this ->createMock (ModeConfiguredInterface::class);
65
78
66
79
$ this ->model = $ objectManager ->getObject (
67
80
ConfigManager::class,
@@ -70,6 +83,7 @@ protected function setUp(): void
70
83
'storeModel ' => $ this ->storeMock ,
71
84
'state ' => $ this ->stateMock ,
72
85
'request ' => $ this ->requestMock ,
86
+ 'modeConfiguredFactory ' => $ this ->modeConfiguredFactoryMock
73
87
]
74
88
);
75
89
}
@@ -107,9 +121,14 @@ public function testConfiguredCSPForAdminArea()
107
121
$ this ->scopeConfigMock ->expects ($ this ->any ())
108
122
->method ('getValue ' )
109
123
->willReturn ('testReportUri ' );
124
+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
125
+ ->method ('create ' )
126
+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
127
+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
128
+
110
129
$ result = $ this ->model ->getConfigured ();
111
130
112
- $ this ->assertInstanceOf (ModeConfigured ::class, $ result );
131
+ $ this ->assertInstanceOf (ModeConfiguredInterface ::class, $ result );
113
132
}
114
133
115
134
/**
@@ -139,11 +158,14 @@ public function testCheckoutPageReportOnly(): void
139
158
})
140
159
->willReturnOnConsecutiveCalls (true , 'testReportUri ' );
141
160
161
+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
162
+ ->method ('create ' )
163
+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
164
+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
165
+
142
166
$ result = $ this ->model ->getConfigured ();
143
167
144
- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
145
- $ this ->assertTrue ($ result ->isReportOnly ());
146
- $ this ->assertEquals ($ result ->getReportUri (), 'testReportUri ' );
168
+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
147
169
}
148
170
149
171
/**
@@ -174,10 +196,13 @@ public function testNonCheckoutPageReportOnly(): void
174
196
})
175
197
->willReturnOnConsecutiveCalls (null , true , null , 'testPageReportUri ' );
176
198
199
+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
200
+ ->method ('create ' )
201
+ ->with (['reportOnly ' => true , 'reportUri ' => 'testPageReportUri ' ])
202
+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
203
+
177
204
$ result = $ this ->model ->getConfigured ();
178
205
179
- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
180
- $ this ->assertTrue ($ result ->isReportOnly ());
181
- $ this ->assertEquals ($ result ->getReportUri (), 'testPageReportUri ' );
206
+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
182
207
}
183
208
}
0 commit comments