File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,8 @@ public function __construct(
87
87
public function cancel ($ id )
88
88
{
89
89
$ order = $ this ->orderRepository ->get ($ id );
90
- if ((bool )$ order ->cancel ()) {
90
+ if ((bool )$ order ->canCancel ()) {
91
+ $ order ->cancel ();
91
92
$ this ->orderRepository ->save ($ order );
92
93
return true ;
93
94
}
Original file line number Diff line number Diff line change @@ -163,9 +163,30 @@ public function testCancel()
163
163
$ this ->orderMock ->expects ($ this ->once ())
164
164
->method ('cancel ' )
165
165
->willReturn ($ this ->orderMock );
166
+ $ this ->orderMock ->expects ($ this ->once ())
167
+ ->method ('canCancel ' )
168
+ ->willReturn (true );
166
169
$ this ->assertTrue ($ this ->orderService ->cancel (123 ));
167
170
}
168
171
172
+ /**
173
+ * test for Order::cancel() fail case
174
+ */
175
+ public function testCancelFailed ()
176
+ {
177
+ $ this ->orderRepositoryMock ->expects ($ this ->once ())
178
+ ->method ('get ' )
179
+ ->with (123 )
180
+ ->willReturn ($ this ->orderMock );
181
+ $ this ->orderMock ->expects ($ this ->never ())
182
+ ->method ('cancel ' )
183
+ ->willReturn ($ this ->orderMock );
184
+ $ this ->orderMock ->expects ($ this ->once ())
185
+ ->method ('canCancel ' )
186
+ ->willReturn (false );
187
+ $ this ->assertFalse ($ this ->orderService ->cancel (123 ));
188
+ }
189
+
169
190
public function testGetCommentsList ()
170
191
{
171
192
$ this ->filterBuilderMock ->expects ($ this ->once ())
You can’t perform that action at this time.
0 commit comments