88
99namespace Magento \Csp \Test \Unit \Model \Mode ;
1010
11+ use Magento \Csp \Api \Data \ModeConfiguredInterface ;
1112use Magento \Csp \Model \Mode \ConfigManager ;
12- use Magento \Csp \Model \Mode \Data \ModeConfigured ;
13+ use Magento \Csp \Model \Mode \Data \ModeConfiguredFactory ;
1314use Magento \Framework \App \Area ;
1415use Magento \Framework \App \Config \ScopeConfigInterface ;
1516use Magento \Framework \App \Request \Http ;
@@ -51,6 +52,16 @@ class ConfigManagerTest extends TestCase
5152 */
5253 private $ requestMock ;
5354
55+ /**
56+ * @var ModeConfiguredFactory
57+ */
58+ private $ modeConfiguredFactoryMock ;
59+
60+ /**
61+ * @var ModeConfiguredInterface
62+ */
63+ private $ modeConfiguredInterfaceMock ;
64+
5465 /**
5566 * Set Up
5667 */
@@ -62,6 +73,8 @@ protected function setUp(): void
6273 $ this ->storeMock = $ this ->createMock (Store::class);
6374 $ this ->stateMock = $ this ->createMock (State::class);
6475 $ this ->requestMock = $ this ->createMock (Http::class);
76+ $ this ->modeConfiguredFactoryMock = $ this ->createPartialMock (ModeConfiguredFactory::class, ['create ' ]);
77+ $ this ->modeConfiguredInterfaceMock = $ this ->createMock (ModeConfiguredInterface::class);
6578
6679 $ this ->model = $ objectManager ->getObject (
6780 ConfigManager::class,
@@ -70,6 +83,7 @@ protected function setUp(): void
7083 'storeModel ' => $ this ->storeMock ,
7184 'state ' => $ this ->stateMock ,
7285 'request ' => $ this ->requestMock ,
86+ 'modeConfiguredFactory ' => $ this ->modeConfiguredFactoryMock
7387 ]
7488 );
7589 }
@@ -107,9 +121,14 @@ public function testConfiguredCSPForAdminArea()
107121 $ this ->scopeConfigMock ->expects ($ this ->any ())
108122 ->method ('getValue ' )
109123 ->willReturn ('testReportUri ' );
124+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
125+ ->method ('create ' )
126+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
127+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
128+
110129 $ result = $ this ->model ->getConfigured ();
111130
112- $ this ->assertInstanceOf (ModeConfigured ::class, $ result );
131+ $ this ->assertInstanceOf (ModeConfiguredInterface ::class, $ result );
113132 }
114133
115134 /**
@@ -139,11 +158,14 @@ public function testCheckoutPageReportOnly(): void
139158 })
140159 ->willReturnOnConsecutiveCalls (true , 'testReportUri ' );
141160
161+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
162+ ->method ('create ' )
163+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
164+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
165+
142166 $ result = $ this ->model ->getConfigured ();
143167
144- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
145- $ this ->assertTrue ($ result ->isReportOnly ());
146- $ this ->assertEquals ($ result ->getReportUri (), 'testReportUri ' );
168+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
147169 }
148170
149171 /**
@@ -174,10 +196,13 @@ public function testNonCheckoutPageReportOnly(): void
174196 })
175197 ->willReturnOnConsecutiveCalls (null , true , null , 'testPageReportUri ' );
176198
199+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
200+ ->method ('create ' )
201+ ->with (['reportOnly ' => true , 'reportUri ' => 'testPageReportUri ' ])
202+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
203+
177204 $ result = $ this ->model ->getConfigured ();
178205
179- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
180- $ this ->assertTrue ($ result ->isReportOnly ());
181- $ this ->assertEquals ($ result ->getReportUri (), 'testPageReportUri ' );
206+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
182207 }
183208}
0 commit comments