@@ -132,12 +132,14 @@ protected function setUp()
132
132
]
133
133
);
134
134
}
135
- public function testGetData ()
135
+
136
+ public function testGetRssData ()
136
137
{
137
- $ this ->orderFactory ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->order ));
138
- $ this ->requestInterface ->expects ($ this ->any ())->method ('getParam ' )
139
- ->with ('data ' )
140
- ->will ($ this ->returnValue ('eyJvcmRlcl9pZCI6MSwiaW5jcmVtZW50X2lkIjoiMTAwMDAwMDAxIiwiY3VzdG9tZXJfaWQiOjF9 ' ));
138
+ $ this ->orderFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->order );
139
+ $ requestData = base64_encode ('{"order_id":1,"increment_id":"100000001","customer_id":1} ' );
140
+
141
+ $ this ->requestInterface ->expects ($ this ->any ())->method ('getParam ' )->with ('data ' )->willReturn ($ requestData );
142
+
141
143
$ resource = $ this ->getMockBuilder ('\Magento\Sales\Model\ResourceModel\Order\Rss\OrderStatus ' )
142
144
->setMethods (['getAllCommentCollection ' ])
143
145
->disableOriginalConstructor ()
@@ -148,15 +150,34 @@ public function testGetData()
148
150
'created_at ' => '2014-10-09 18:25:50 ' ,
149
151
'comment ' => 'Some comment ' ,
150
152
];
151
- $ resource ->expects ($ this ->once ())->method ('getAllCommentCollection ' )->will ( $ this -> returnValue ( [$ comment ]) );
152
- $ this ->orderStatusFactory ->expects ($ this ->once ())->method ('create ' )->will ( $ this -> returnValue ( $ resource) );
153
+ $ resource ->expects ($ this ->once ())->method ('getAllCommentCollection ' )->willReturn ( [$ comment ]);
154
+ $ this ->orderStatusFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ( $ resource );
153
155
$ this ->urlInterface ->expects ($ this ->any ())->method ('getUrl ' )
154
156
->with ('sales/order/view ' , ['order_id ' => 1 ])
155
157
->will ($ this ->returnValue ('http://magento.com/sales/order/view/order_id/1 ' ));
156
158
157
159
$ this ->assertEquals ($ this ->feedData , $ this ->model ->getRssData ());
158
160
}
159
161
162
+ /**
163
+ * @expectedException \InvalidArgumentException
164
+ * @expectedExceptionMessage Order not found.
165
+ */
166
+ public function testGetRssDataWithError ()
167
+ {
168
+ $ this ->orderFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->order );
169
+
170
+ $ requestData = base64_encode ('{"order_id":"1","increment_id":true,"customer_id":true} ' );
171
+
172
+ $ this ->requestInterface ->expects ($ this ->any ())->method ('getParam ' )->with ('data ' )->willReturn ($ requestData );
173
+
174
+ $ this ->orderStatusFactory ->expects ($ this ->never ())->method ('create ' );
175
+
176
+ $ this ->urlInterface ->expects ($ this ->never ())->method ('getUrl ' );
177
+
178
+ $ this ->assertEquals ($ this ->feedData , $ this ->model ->getRssData ());
179
+ }
180
+
160
181
public function testIsAllowed ()
161
182
{
162
183
$ this ->scopeConfigInterface ->expects ($ this ->once ())->method ('getValue ' )
@@ -165,13 +186,29 @@ public function testIsAllowed()
165
186
$ this ->assertTrue ($ this ->model ->isAllowed ());
166
187
}
167
188
168
- public function testGetCacheKey ()
189
+ /**
190
+ * @param string $requestData
191
+ * @param string $result
192
+ * @dataProvider getCacheKeyDataProvider
193
+ */
194
+ public function testGetCacheKey ($ requestData , $ result )
169
195
{
170
196
$ this ->requestInterface ->expects ($ this ->any ())->method ('getParam ' )
171
197
->with ('data ' )
172
- ->will ($ this ->returnValue (' eyJvcmRlcl9pZCI6MSwiaW5jcmVtZW50X2lkIjoiMTAwMDAwMDAxIiwiY3VzdG9tZXJfaWQiOjF9 ' ));
198
+ ->will ($ this ->returnValue ($ requestData ));
173
199
$ this ->orderFactory ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->order ));
174
- $ this ->assertEquals ('rss_order_status_data_ ' . md5 ('11000000011 ' ), $ this ->model ->getCacheKey ());
200
+ $ this ->assertEquals ('rss_order_status_data_ ' . $ result , $ this ->model ->getCacheKey ());
201
+ }
202
+
203
+ /**
204
+ * @return array
205
+ */
206
+ public function getCacheKeyDataProvider ()
207
+ {
208
+ return [
209
+ [base64_encode ('{"order_id":1,"increment_id":"100000001","customer_id":1} ' ), md5 ('11000000011 ' )],
210
+ [base64_encode ('{"order_id":"1","increment_id":true,"customer_id":true} ' ), '' ]
211
+ ];
175
212
}
176
213
177
214
public function testGetCacheLifetime ()
0 commit comments