14
14
use Magento \Customer \Api \Data \CustomerInterface ;
15
15
use Magento \Framework \App \RequestInterface ;
16
16
use Magento \Multishipping \Model \Cart \Controller \CartPlugin ;
17
+ use Magento \Multishipping \Model \DisableMultishipping ;
17
18
use Magento \Quote \Api \CartRepositoryInterface ;
18
19
use Magento \Quote \Model \Quote ;
19
20
use Magento \Quote \Model \Quote \Address ;
@@ -47,10 +48,12 @@ protected function setUp(): void
47
48
$ this ->cartRepositoryMock = $ this ->getMockForAbstractClass (CartRepositoryInterface::class);
48
49
$ this ->checkoutSessionMock = $ this ->createMock (Session::class);
49
50
$ this ->addressRepositoryMock = $ this ->getMockForAbstractClass (AddressRepositoryInterface::class);
51
+ $ disableMultishippingMock = $ this ->createMock (DisableMultishipping::class);
50
52
$ this ->model = new CartPlugin (
51
53
$ this ->cartRepositoryMock ,
52
54
$ this ->checkoutSessionMock ,
53
- $ this ->addressRepositoryMock
55
+ $ this ->addressRepositoryMock ,
56
+ $ disableMultishippingMock
54
57
);
55
58
}
56
59
@@ -65,33 +68,41 @@ public function testBeforeDispatch()
65
68
'getShippingAddress ' ,
66
69
'getCustomer '
67
70
]);
68
- $ this ->checkoutSessionMock ->expects ($ this ->once ())->method ('getQuote ' )->willReturn ($ quoteMock );
71
+ $ this ->checkoutSessionMock ->method ('getQuote ' )
72
+ ->willReturn ($ quoteMock );
69
73
70
74
$ addressMock = $ this ->createMock (Address::class);
71
- $ addressMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ addressId );
75
+ $ addressMock ->method ('getId ' )
76
+ ->willReturn ($ addressId );
72
77
73
- $ quoteMock ->expects ($ this ->once ())->method ('isMultipleShippingAddresses ' )->willReturn (true );
74
- $ quoteMock ->expects ($ this ->once ())->method ('getAllShippingAddresses ' )->willReturn ([$ addressMock ]);
75
- $ quoteMock ->expects ($ this ->once ())->method ('removeAddress ' )->with ($ addressId )->willReturnSelf ();
78
+ $ quoteMock ->method ('isMultipleShippingAddresses ' )
79
+ ->willReturn (true );
80
+ $ quoteMock ->method ('getAllShippingAddresses ' )
81
+ ->willReturn ([$ addressMock ]);
82
+ $ quoteMock ->method ('removeAddress ' )
83
+ ->with ($ addressId )->willReturnSelf ();
76
84
77
85
$ shippingAddressMock = $ this ->createMock (Address::class);
78
- $ quoteMock ->expects ($ this ->once ())->method ('getShippingAddress ' )->willReturn ($ shippingAddressMock );
86
+ $ quoteMock ->method ('getShippingAddress ' )
87
+ ->willReturn ($ shippingAddressMock );
79
88
$ customerMock = $ this ->getMockForAbstractClass (CustomerInterface::class);
80
- $ quoteMock ->expects ($ this ->once ())->method ('getCustomer ' )->willReturn ($ customerMock );
81
- $ customerMock ->expects ($ this ->once ())->method ('getDefaultShipping ' )->willReturn ($ customerAddressId );
89
+ $ quoteMock ->method ('getCustomer ' )
90
+ ->willReturn ($ customerMock );
91
+ $ customerMock ->method ('getDefaultShipping ' )
92
+ ->willReturn ($ customerAddressId );
82
93
83
94
$ customerAddressMock = $ this ->getMockForAbstractClass (AddressInterface::class);
84
- $ this ->addressRepositoryMock ->expects ($ this ->once ())
85
- ->method ('getById ' )
95
+ $ this ->addressRepositoryMock ->method ('getById ' )
86
96
->with ($ customerAddressId )
87
97
->willReturn ($ customerAddressMock );
88
98
89
- $ shippingAddressMock ->expects ($ this ->once ())
90
- ->method ('importCustomerAddressData ' )
99
+ $ shippingAddressMock ->method ('importCustomerAddressData ' )
91
100
->with ($ customerAddressMock )
92
101
->willReturnSelf ();
93
102
94
- $ this ->cartRepositoryMock ->expects ($ this ->once ())->method ('save ' )->with ($ quoteMock );
103
+ $ this ->cartRepositoryMock ->expects ($ this ->once ())
104
+ ->method ('save ' )
105
+ ->with ($ quoteMock );
95
106
96
107
$ this ->model ->beforeDispatch (
97
108
$ this ->createMock (Cart::class),
0 commit comments