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