59 $this->configMock = $this->createMock(\
Magento\Framework\View\Page\Config::class);
60 $this->titleMock = $this->createMock(\
Magento\Framework\View\Page\Title::class);
61 $this->layoutMock = $this->createMock(\
Magento\Framework\View\Layout::class);
62 $this->viewMock = $this->createMock(\
Magento\Framework\
App\ViewInterface::class);
64 ->disableOriginalConstructor()
66 ->getMockForAbstractClass();
68 ->disableOriginalConstructor()
70 ->getMockForAbstractClass();
71 $contextMock = $this->createMock(\
Magento\Framework\
App\Action\Context::class);
72 $contextMock->expects($this->atLeastOnce())
73 ->method(
'getRequest')
74 ->will($this->returnValue(
$request));
75 $contextMock->expects($this->atLeastOnce())
76 ->method(
'getResponse')
78 $contextMock->expects($this->any())->method(
'getView')->willReturn($this->viewMock);
79 $methods = [
'setTitle',
'getTitle',
'setSuccessUrl',
'setErrorUrl',
'setBackUrl',
'__wakeUp'];
80 $this->addressFormMock =
81 $this->createPartialMock(\
Magento\Customer\Block\Address\Edit::class,
$methods);
82 $this->urlMock = $this->createMock(\
Magento\Framework\UrlInterface::class);
83 $contextMock->expects($this->any())->method(
'getUrl')->willReturn($this->urlMock);
84 $this->pageMock = $this->createMock(\
Magento\Framework\View\Result\Page::class);
85 $this->pageMock->expects($this->any())->method(
'getConfig')->willReturn($this->configMock);
86 $this->configMock->expects($this->any())->method(
'getTitle')->willReturn($this->titleMock);
87 $this->viewMock->expects($this->any())->method(
'getPage')->willReturn($this->pageMock);
89 \
Magento\Multishipping\Controller\Checkout\Address\NewBilling::class,
90 [
'context' => $contextMock]
96 $this->viewMock->expects($this->once())->method(
'loadLayout')->willReturnSelf();
97 $this->viewMock->expects($this->any())->method(
'getLayout')->willReturn($this->layoutMock);
99 ->expects($this->once())
101 ->with(
'customer_address_edit')
102 ->willReturn($this->addressFormMock);
103 $this->addressFormMock
104 ->expects($this->once())
106 ->with(
'Create Billing Address')
108 $helperMock = $this->createPartialMock(\
Magento\Multishipping\Helper\Data::class, [
'__']);
109 $helperMock->expects($this->any())->method(
'__')->willReturn(
'Create Billing Address');
111 [
'*/*/selectBilling',
null,
'success/url'],
112 [
'*/*/*',
null,
'error/url'],
114 $this->urlMock->expects($this->any())->method(
'getUrl')->willReturnMap($valueMap);
115 $this->addressFormMock->expects($this->once())->method(
'setSuccessUrl')->with(
'success/url')->willReturnSelf();
116 $this->addressFormMock->expects($this->once())->method(
'setErrorUrl')->with(
'error/url')->willReturnSelf();
118 $this->titleMock->expects($this->once())->method(
'getDefault')->willReturn(
'default_title');
119 $this->addressFormMock->expects($this->once())->method(
'getTitle')->willReturn(
'Address title');
120 $this->titleMock->expects($this->once())->method(
'set')->with(
'Address title - default_title');
121 $this->addressFormMock->expects($this->once())->method(
'setBackUrl')->with(
'success/url');
122 $this->viewMock->expects($this->once())->method(
'renderLayout');
123 $this->controller->execute();
128 $this->viewMock->expects($this->once())->method(
'loadLayout')->willReturnSelf();
129 $this->viewMock->expects($this->any())->method(
'getLayout')->willReturn($this->layoutMock);
131 ->expects($this->once())
133 ->with(
'customer_address_edit');
134 $this->urlMock->expects($this->never())->method(
'getUrl');
135 $this->viewMock->expects($this->once())->method(
'renderLayout');
136 $this->controller->execute();
testExecuteWhenCustomerAddressBlockNotExist()