74 $this->configMock = $this->createMock(\
Magento\Framework\View\Page\Config::class);
76 $this->createMock(\
Magento\Multishipping\Model\Checkout\Type\Multishipping::class);
77 $this->titleMock = $this->createMock(\
Magento\Framework\View\Page\Title::class);
78 $this->layoutMock = $this->createMock(\
Magento\Framework\View\Layout::class);
79 $this->viewMock = $this->createMock(\
Magento\Framework\
App\ViewInterface::class);
80 $this->objectManagerMock = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
82 $this->createMock(\
Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class);
84 [\Magento\Multishipping\Model\Checkout\Type\Multishipping\State::class,
$this->stateMock],
87 $this->objectManagerMock->expects($this->any())->method(
'get')->willReturnMap($valueMap);
89 ->disableOriginalConstructor()
91 ->getMockForAbstractClass();
93 ->disableOriginalConstructor()
95 ->getMockForAbstractClass();
96 $contextMock = $this->createMock(\
Magento\Framework\
App\Action\Context::class);
97 $contextMock->expects($this->atLeastOnce())
98 ->method(
'getRequest')
99 ->will($this->returnValue(
$request));
100 $contextMock->expects($this->atLeastOnce())
101 ->method(
'getResponse')
103 $contextMock->expects($this->any())->method(
'getView')->willReturn($this->viewMock);
104 $contextMock->expects($this->any())->method(
'getObjectManager')->willReturn($this->objectManagerMock);
105 $methods = [
'setTitle',
'getTitle',
'setSuccessUrl',
'setBackUrl',
'setErrorUrl',
'__wakeUp'];
106 $this->addressFormMock =
107 $this->createPartialMock(\
Magento\Customer\Block\Address\Edit::class,
$methods);
108 $this->urlMock = $this->createMock(\
Magento\Framework\UrlInterface::class);
109 $contextMock->expects($this->any())->method(
'getUrl')->willReturn($this->urlMock);
110 $this->pageMock = $this->createMock(\
Magento\Framework\View\Result\Page::class);
111 $this->pageMock->expects($this->any())->method(
'getConfig')->willReturn($this->configMock);
112 $this->configMock->expects($this->any())->method(
'getTitle')->willReturn($this->titleMock);
113 $this->viewMock->expects($this->any())->method(
'getPage')->willReturn($this->pageMock);
115 \
Magento\Multishipping\Controller\Checkout\Address\NewShipping::class,
116 [
'context' => $contextMock]
129 ->expects($this->once())
130 ->method(
'setActiveStep')
131 ->with(\
Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_SELECT_ADDRESSES);
132 $this->viewMock->expects($this->once())->method(
'loadLayout')->willReturnSelf();
133 $this->viewMock->expects($this->any())->method(
'getLayout')->willReturn($this->layoutMock);
135 ->expects($this->once())
137 ->with(
'customer_address_edit')
138 ->willReturn($this->addressFormMock);
139 $this->addressFormMock
140 ->expects($this->once())
142 ->with(
'Create Shipping Address')
144 $helperMock = $this->createPartialMock(\
Magento\Multishipping\Helper\Data::class, [
'__']);
145 $helperMock->expects($this->any())->method(
'__')->willReturn(
'Create Shipping Address');
146 $this->addressFormMock->expects($this->once())->method(
'setSuccessUrl')->with(
'success/url')->willReturnSelf();
147 $this->addressFormMock->expects($this->once())->method(
'setErrorUrl')->with(
'error/url')->willReturnSelf();
149 [
'*/*/shippingSaved',
null,
'success/url'],
150 [
'*/*/*',
null,
'error/url'],
151 [$backUrl,
null,
$url]
153 $this->urlMock->expects($this->any())->method(
'getUrl')->willReturnMap($valueMap);
154 $this->titleMock->expects($this->once())->method(
'getDefault')->willReturn(
'default_title');
155 $this->addressFormMock->expects($this->once())->method(
'getTitle')->willReturn(
'Address title');
156 $this->titleMock->expects($this->once())->method(
'set')->with(
'Address title - default_title');
158 ->expects($this->once())
159 ->method(
'getCustomerDefaultShippingAddress')
161 $this->addressFormMock->expects($this->once())->method(
'setBackUrl')->with(
$url);
162 $this->viewMock->expects($this->once())->method(
'renderLayout');
163 $this->controller->execute();
172 'shipping_address_exists' => [
'*/checkout/addresses',
'shipping_address',
'back/address'],
173 'shipping_address_not_exist' => [
'*/cart/',
null,
'back/cart']
180 ->expects($this->once())
181 ->method(
'setActiveStep')
182 ->with(\
Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_SELECT_ADDRESSES);
183 $this->viewMock->expects($this->once())->method(
'loadLayout')->willReturnSelf();
184 $this->viewMock->expects($this->any())->method(
'getLayout')->willReturn($this->layoutMock);
186 ->expects($this->once())
188 ->with(
'customer_address_edit');
189 $this->urlMock->expects($this->never())->method(
'getUrl');
190 $this->viewMock->expects($this->once())->method(
'renderLayout');
191 $this->controller->execute();
testExecute($backUrl, $shippingAddress, $url)
testExecuteWhenCustomerAddressBlockNotExist()