3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Wishlist \Test \Unit \Controller \Shared ;
7
8
8
9
use Magento \Catalog \Model \Product ;
10
+ use Magento \Catalog \Model \Product \Exception ;
9
11
use Magento \Checkout \Helper \Cart as CartHelper ;
10
12
use Magento \Checkout \Model \Cart ;
11
13
use Magento \Framework \App \Action \Context as ActionContext ;
23
25
use Magento \Wishlist \Model \Item \OptionFactory ;
24
26
use Magento \Wishlist \Model \ItemFactory ;
25
27
use Magento \Wishlist \Model \ResourceModel \Item \Option \Collection as OptionCollection ;
28
+ use PHPUnit \Framework \MockObject \MockObject ;
29
+ use PHPUnit \Framework \TestCase ;
26
30
27
31
/**
28
32
* @SuppressWarnings(PHPMD.TooManyFields)
29
33
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30
34
*/
31
- class CartTest extends \ PHPUnit \ Framework \ TestCase
35
+ class CartTest extends TestCase
32
36
{
33
- /** @var SharedCart|\PHPUnit\Framework\MockObject\ MockObject */
37
+ /** @var SharedCart|MockObject */
34
38
protected $ model ;
35
39
36
- /** @var RequestInterface|\PHPUnit\Framework\MockObject\ MockObject */
40
+ /** @var RequestInterface|MockObject */
37
41
protected $ request ;
38
42
39
- /** @var ManagerInterface|\PHPUnit\Framework\MockObject\ MockObject */
43
+ /** @var ManagerInterface|MockObject */
40
44
protected $ messageManager ;
41
45
42
- /** @var ActionContext|\PHPUnit\Framework\MockObject\ MockObject */
46
+ /** @var ActionContext|MockObject */
43
47
protected $ context ;
44
48
45
- /** @var Cart|\PHPUnit\Framework\MockObject\ MockObject */
49
+ /** @var Cart|MockObject */
46
50
protected $ cart ;
47
51
48
- /** @var CartHelper|\PHPUnit\Framework\MockObject\ MockObject */
52
+ /** @var CartHelper|MockObject */
49
53
protected $ cartHelper ;
50
54
51
- /** @var Quote|\PHPUnit\Framework\MockObject\ MockObject */
55
+ /** @var Quote|MockObject */
52
56
protected $ quote ;
53
57
54
- /** @var OptionCollection|\PHPUnit\Framework\MockObject\ MockObject */
58
+ /** @var OptionCollection|MockObject */
55
59
protected $ optionCollection ;
56
60
57
- /** @var OptionFactory|\PHPUnit\Framework\MockObject\ MockObject */
61
+ /** @var OptionFactory|MockObject */
58
62
protected $ optionFactory ;
59
63
60
- /** @var Option|\PHPUnit\Framework\MockObject\ MockObject */
64
+ /** @var Option|MockObject */
61
65
protected $ option ;
62
66
63
- /** @var ItemFactory|\PHPUnit\Framework\MockObject\ MockObject */
67
+ /** @var ItemFactory|MockObject */
64
68
protected $ itemFactory ;
65
69
66
- /** @var Item|\PHPUnit\Framework\MockObject\ MockObject */
70
+ /** @var Item|MockObject */
67
71
protected $ item ;
68
72
69
- /** @var Escaper|\PHPUnit\Framework\MockObject\ MockObject */
73
+ /** @var Escaper|MockObject */
70
74
protected $ escaper ;
71
75
72
- /** @var RedirectInterface|\PHPUnit\Framework\MockObject\ MockObject */
76
+ /** @var RedirectInterface|MockObject */
73
77
protected $ redirect ;
74
78
75
- /** @var ResultFactory|\PHPUnit\Framework\MockObject\ MockObject */
79
+ /** @var ResultFactory|MockObject */
76
80
protected $ resultFactory ;
77
81
78
- /** @var Redirect|\PHPUnit\Framework\MockObject\ MockObject */
82
+ /** @var Redirect|MockObject */
79
83
protected $ resultRedirect ;
80
84
81
- /** @var Product|\PHPUnit\Framework\MockObject\ MockObject */
85
+ /** @var Product|MockObject */
82
86
protected $ product ;
83
87
84
88
protected function setUp ()
85
89
{
86
- $ this ->request = $ this ->getMockBuilder (\ Magento \ Framework \ App \ RequestInterface::class)
90
+ $ this ->request = $ this ->getMockBuilder (RequestInterface::class)
87
91
->getMockForAbstractClass ();
88
92
89
- $ this ->redirect = $ this ->getMockBuilder (\ Magento \ Framework \ App \ Response \ RedirectInterface::class)
93
+ $ this ->redirect = $ this ->getMockBuilder (RedirectInterface::class)
90
94
->getMockForAbstractClass ();
91
95
92
- $ this ->messageManager = $ this ->getMockBuilder (\ Magento \ Framework \ Message \ ManagerInterface::class)
96
+ $ this ->messageManager = $ this ->getMockBuilder (ManagerInterface::class)
93
97
->getMockForAbstractClass ();
94
98
95
- $ this ->resultRedirect = $ this ->getMockBuilder (\ Magento \ Framework \ Controller \ Result \ Redirect::class)
99
+ $ this ->resultRedirect = $ this ->getMockBuilder (Redirect::class)
96
100
->disableOriginalConstructor ()
97
101
->getMock ();
98
102
99
- $ this ->resultFactory = $ this ->getMockBuilder (\ Magento \ Framework \ Controller \ ResultFactory::class)
103
+ $ this ->resultFactory = $ this ->getMockBuilder (ResultFactory::class)
100
104
->disableOriginalConstructor ()
101
105
->getMock ();
102
106
$ this ->resultFactory ->expects ($ this ->once ())
103
107
->method ('create ' )
104
108
->with (ResultFactory::TYPE_REDIRECT )
105
109
->willReturn ($ this ->resultRedirect );
106
110
107
- $ this ->context = $ this ->getMockBuilder (\ Magento \ Framework \ App \ Action \Context ::class)
111
+ $ this ->context = $ this ->getMockBuilder (ActionContext ::class)
108
112
->disableOriginalConstructor ()
109
113
->getMock ();
110
114
$ this ->context ->expects ($ this ->any ())
@@ -120,62 +124,65 @@ protected function setUp()
120
124
->method ('getResultFactory ' )
121
125
->willReturn ($ this ->resultFactory );
122
126
123
- $ this ->cart = $ this ->getMockBuilder (\ Magento \ Checkout \ Model \ Cart::class)
127
+ $ this ->cart = $ this ->getMockBuilder (Cart::class)
124
128
->disableOriginalConstructor ()
125
129
->getMock ();
126
130
127
- $ this ->cartHelper = $ this ->getMockBuilder (\ Magento \ Checkout \ Helper \Cart ::class)
131
+ $ this ->cartHelper = $ this ->getMockBuilder (CartHelper ::class)
128
132
->disableOriginalConstructor ()
129
133
->getMock ();
130
134
131
- $ this ->quote = $ this ->getMockBuilder (\ Magento \ Quote \ Model \ Quote::class)
135
+ $ this ->quote = $ this ->getMockBuilder (Quote::class)
132
136
->disableOriginalConstructor ()
133
137
->setMethods (['getHasError ' ])
134
138
->getMock ();
135
139
136
140
$ this ->optionCollection = $ this ->getMockBuilder (
137
- \ Magento \ Wishlist \ Model \ ResourceModel \ Item \ Option \Collection ::class
141
+ OptionCollection ::class
138
142
)->disableOriginalConstructor ()->getMock ();
139
143
140
- $ this ->option = $ this ->getMockBuilder (\ Magento \ Wishlist \ Model \ Item \ Option::class)
144
+ $ this ->option = $ this ->getMockBuilder (Option::class)
141
145
->disableOriginalConstructor ()
142
146
->getMock ();
143
147
144
- $ this ->optionFactory = $ this ->getMockBuilder (\ Magento \ Wishlist \ Model \ Item \ OptionFactory::class)
148
+ $ this ->optionFactory = $ this ->getMockBuilder (OptionFactory::class)
145
149
->disableOriginalConstructor ()
146
150
->setMethods (['create ' ])
147
151
->getMock ();
148
152
$ this ->optionFactory ->expects ($ this ->once ())
149
153
->method ('create ' )
150
154
->willReturn ($ this ->option );
151
155
152
- $ this ->item = $ this ->getMockBuilder (\ Magento \ Wishlist \ Model \ Item::class)
156
+ $ this ->item = $ this ->getMockBuilder (Item::class)
153
157
->disableOriginalConstructor ()
154
158
->getMock ();
155
159
156
- $ this ->itemFactory = $ this ->getMockBuilder (\ Magento \ Wishlist \ Model \ ItemFactory::class)
160
+ $ this ->itemFactory = $ this ->getMockBuilder (ItemFactory::class)
157
161
->disableOriginalConstructor ()
158
162
->setMethods (['create ' ])
159
163
->getMock ();
160
164
$ this ->itemFactory ->expects ($ this ->once ())
161
165
->method ('create ' )
162
166
->willReturn ($ this ->item );
163
167
164
- $ this ->escaper = $ this ->getMockBuilder (\ Magento \ Framework \ Escaper::class)
168
+ $ this ->escaper = $ this ->getMockBuilder (Escaper::class)
165
169
->disableOriginalConstructor ()
166
170
->getMock ();
167
171
168
- $ this ->product = $ this ->getMockBuilder (\ Magento \ Catalog \ Model \ Product::class)
172
+ $ this ->product = $ this ->getMockBuilder (Product::class)
169
173
->disableOriginalConstructor ()
170
174
->getMock ();
171
175
172
176
$ this ->model = new SharedCart (
173
- $ this ->context ,
174
177
$ this ->cart ,
175
178
$ this ->optionFactory ,
176
179
$ this ->itemFactory ,
177
180
$ this ->cartHelper ,
178
- $ this ->escaper
181
+ $ this ->escaper ,
182
+ $ this ->request ,
183
+ $ this ->redirect ,
184
+ $ this ->messageManager ,
185
+ $ this ->resultFactory
179
186
);
180
187
}
181
188
@@ -353,7 +360,7 @@ public function testExecuteProductException()
353
360
354
361
$ this ->option ->expects ($ this ->once ())
355
362
->method ('getCollection ' )
356
- ->willThrowException (new \ Magento \ Catalog \ Model \ Product \ Exception (__ ('LocalizedException ' )));
363
+ ->willThrowException (new Exception (__ ('LocalizedException ' )));
357
364
358
365
$ this ->resultRedirect ->expects ($ this ->once ())
359
366
->method ('setUrl ' )
0 commit comments