16
16
17
17
/**
18
18
* Unit test for \Magento\Quote\Model\ChangeQuoteControl
19
- *
20
- * Class \Magento\Quote\Test\Unit\Model\ChangeQuoteControlTest
21
19
*/
22
20
class ChangeQuoteControlTest extends TestCase
23
21
{
24
- /**
25
- * @var ObjectManager
26
- */
27
- protected $ objectManager ;
28
-
29
22
/**
30
23
* @var ChangeQuoteControl
31
24
*/
32
25
protected $ model ;
33
26
34
27
/**
35
- * @var MockObject
28
+ * @var MockObject|UserContextInterface
36
29
*/
37
30
protected $ userContextMock ;
38
31
39
32
/**
40
- * @var MockObject
33
+ * @var MockObject|CartInterface
41
34
*/
42
35
protected $ quoteMock ;
43
36
44
37
protected function setUp (): void
45
38
{
46
- $ this ->objectManager = new ObjectManager ($ this );
47
39
$ this ->userContextMock = $ this ->getMockForAbstractClass (UserContextInterface::class);
48
40
49
- $ this ->model = $ this ->objectManager ->getObject (
50
- ChangeQuoteControl::class,
51
- [
52
- 'userContext ' => $ this ->userContextMock
53
- ]
54
- );
55
-
56
- $ this ->quoteMock = $ this ->getMockForAbstractClass (
57
- CartInterface::class,
58
- [],
59
- '' ,
60
- false ,
61
- true ,
62
- true ,
63
- ['getCustomerId ' ]
64
- );
41
+ $ this ->model = new ChangeQuoteControl ($ this ->userContextMock );
42
+
43
+ $ this ->quoteMock = $ this ->getMockBuilder (CartInterface::class)
44
+ ->disableOriginalConstructor ()
45
+ ->addMethods (['getCustomerId ' ])
46
+ ->getMockForAbstractClass ();
65
47
}
66
48
67
- /**
68
- * Test if the quote is belonged to customer
69
- */
70
49
public function testIsAllowedIfTheQuoteIsBelongedToCustomer ()
71
50
{
72
51
$ quoteCustomerId = 1 ;
@@ -80,9 +59,6 @@ public function testIsAllowedIfTheQuoteIsBelongedToCustomer()
80
59
$ this ->assertTrue ($ this ->model ->isAllowed ($ this ->quoteMock ));
81
60
}
82
61
83
- /**
84
- * Test if the quote is not belonged to customer
85
- */
86
62
public function testIsAllowedIfTheQuoteIsNotBelongedToCustomer ()
87
63
{
88
64
$ currentCustomerId = 1 ;
@@ -98,9 +74,6 @@ public function testIsAllowedIfTheQuoteIsNotBelongedToCustomer()
98
74
$ this ->assertFalse ($ this ->model ->isAllowed ($ this ->quoteMock ));
99
75
}
100
76
101
- /**
102
- * Test if the quote is belonged to guest and the context is guest
103
- */
104
77
public function testIsAllowedIfQuoteIsBelongedToGuestAndContextIsGuest ()
105
78
{
106
79
$ quoteCustomerId = null ;
@@ -111,9 +84,6 @@ public function testIsAllowedIfQuoteIsBelongedToGuestAndContextIsGuest()
111
84
$ this ->assertTrue ($ this ->model ->isAllowed ($ this ->quoteMock ));
112
85
}
113
86
114
- /**
115
- * Test if the quote is belonged to customer and the context is guest
116
- */
117
87
public function testIsAllowedIfQuoteIsBelongedToCustomerAndContextIsGuest ()
118
88
{
119
89
$ quoteCustomerId = 1 ;
@@ -124,19 +94,13 @@ public function testIsAllowedIfQuoteIsBelongedToCustomerAndContextIsGuest()
124
94
$ this ->assertFalse ($ this ->model ->isAllowed ($ this ->quoteMock ));
125
95
}
126
96
127
- /**
128
- * Test if the context is admin
129
- */
130
97
public function testIsAllowedIfContextIsAdmin ()
131
98
{
132
99
$ this ->userContextMock ->expects ($ this ->any ())->method ('getUserType ' )
133
100
->willReturn (UserContextInterface::USER_TYPE_ADMIN );
134
101
$ this ->assertTrue ($ this ->model ->isAllowed ($ this ->quoteMock ));
135
102
}
136
103
137
- /**
138
- * Test if the context is integration
139
- */
140
104
public function testIsAllowedIfContextIsIntegration ()
141
105
{
142
106
$ this ->userContextMock ->expects ($ this ->any ())->method ('getUserType ' )
0 commit comments