11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2020 Adobe
4+ * All Rights Reserved .
55 */
6-
76declare (strict_types=1 );
87
98namespace Magento \Csp \Test \Unit \Model \Mode ;
109
10+ use Magento \Csp \Api \Data \ModeConfiguredInterface ;
1111use Magento \Csp \Model \Mode \ConfigManager ;
12- use Magento \Csp \Model \Mode \Data \ModeConfigured ;
12+ use Magento \Csp \Model \Mode \Data \ModeConfiguredFactory ;
1313use Magento \Framework \App \Area ;
1414use Magento \Framework \App \Config \ScopeConfigInterface ;
1515use Magento \Framework \App \Request \Http ;
@@ -51,6 +51,16 @@ class ConfigManagerTest extends TestCase
5151 */
5252 private $ requestMock ;
5353
54+ /**
55+ * @var ModeConfiguredFactory
56+ */
57+ private $ modeConfiguredFactoryMock ;
58+
59+ /**
60+ * @var ModeConfiguredInterface
61+ */
62+ private $ modeConfiguredInterfaceMock ;
63+
5464 /**
5565 * Set Up
5666 */
@@ -62,6 +72,8 @@ protected function setUp(): void
6272 $ this ->storeMock = $ this ->createMock (Store::class);
6373 $ this ->stateMock = $ this ->createMock (State::class);
6474 $ this ->requestMock = $ this ->createMock (Http::class);
75+ $ this ->modeConfiguredFactoryMock = $ this ->createPartialMock (ModeConfiguredFactory::class, ['create ' ]);
76+ $ this ->modeConfiguredInterfaceMock = $ this ->createMock (ModeConfiguredInterface::class);
6577
6678 $ this ->model = $ objectManager ->getObject (
6779 ConfigManager::class,
@@ -70,6 +82,7 @@ protected function setUp(): void
7082 'storeModel ' => $ this ->storeMock ,
7183 'state ' => $ this ->stateMock ,
7284 'request ' => $ this ->requestMock ,
85+ 'modeConfiguredFactory ' => $ this ->modeConfiguredFactoryMock
7386 ]
7487 );
7588 }
@@ -107,9 +120,14 @@ public function testConfiguredCSPForAdminArea()
107120 $ this ->scopeConfigMock ->expects ($ this ->any ())
108121 ->method ('getValue ' )
109122 ->willReturn ('testReportUri ' );
123+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
124+ ->method ('create ' )
125+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
126+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
127+
110128 $ result = $ this ->model ->getConfigured ();
111129
112- $ this ->assertInstanceOf (ModeConfigured ::class, $ result );
130+ $ this ->assertInstanceOf (ModeConfiguredInterface ::class, $ result );
113131 }
114132
115133 /**
@@ -139,11 +157,14 @@ public function testCheckoutPageReportOnly(): void
139157 })
140158 ->willReturnOnConsecutiveCalls (true , 'testReportUri ' );
141159
160+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
161+ ->method ('create ' )
162+ ->with (['reportOnly ' => true , 'reportUri ' => 'testReportUri ' ])
163+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
164+
142165 $ result = $ this ->model ->getConfigured ();
143166
144- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
145- $ this ->assertTrue ($ result ->isReportOnly ());
146- $ this ->assertEquals ($ result ->getReportUri (), 'testReportUri ' );
167+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
147168 }
148169
149170 /**
@@ -174,10 +195,13 @@ public function testNonCheckoutPageReportOnly(): void
174195 })
175196 ->willReturnOnConsecutiveCalls (null , true , null , 'testPageReportUri ' );
176197
198+ $ this ->modeConfiguredFactoryMock ->expects ($ this ->once ())
199+ ->method ('create ' )
200+ ->with (['reportOnly ' => true , 'reportUri ' => 'testPageReportUri ' ])
201+ ->willReturn ($ this ->modeConfiguredInterfaceMock );
202+
177203 $ result = $ this ->model ->getConfigured ();
178204
179- $ this ->assertInstanceOf (ModeConfigured::class, $ result );
180- $ this ->assertTrue ($ result ->isReportOnly ());
181- $ this ->assertEquals ($ result ->getReportUri (), 'testPageReportUri ' );
205+ $ this ->assertInstanceOf (ModeConfiguredInterface::class, $ result );
182206 }
183207}
0 commit comments