/** * {@inheritdoc} */ public function initCheckout() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'initCheckout'); if (!$pluginInfo) { return parent::initCheckout(); } else { return $this->___callPlugins('initCheckout', func_get_args(), $pluginInfo); } }
/** * @dataProvider initCheckoutDataProvider */ public function testInitCheckout($stepData, $isLoggedIn, $isSetStepDataCalled) { $customer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['isMultipleShippingAddresses', 'removeAllAddresses', 'save', 'assignCustomer', 'getData', 'getCustomerId', '__wakeup', 'getBillingAddress', 'setPasswordHash', 'getCheckoutMethod', 'isVirtual', 'getShippingAddress', 'getCustomerData', 'collectTotals'], [], '', false); $quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->will($this->returnValue(true)); $quoteMock->expects($this->once())->method('removeAllAddresses'); $quoteMock->expects($this->once())->method('assignCustomer')->with($customer); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->will($this->returnValue($customer)); $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->will($this->returnValue($isLoggedIn)); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $this->checkoutSessionMock->expects($this->any())->method('getStepData')->will($this->returnValue($stepData)); if ($isSetStepDataCalled) { $this->checkoutSessionMock->expects($this->once())->method('setStepData')->with(key($stepData), 'allow', false); } else { $this->checkoutSessionMock->expects($this->never())->method('setStepData'); } $this->onepage->initCheckout(); }
/** * @dataProvider initCheckoutDataProvider */ public function testInitCheckout($stepData, $isLoggedIn, $isSetStepDataCalled) { $customer = 'customer'; /** @var \Magento\Sales\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ $quoteMock = $this->getMock('Magento\\Sales\\Model\\Quote', [], [], '', false); $quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->will($this->returnValue(true)); $quoteMock->expects($this->once())->method('removeAllAddresses'); $quoteMock->expects($this->once())->method('save'); $quoteMock->expects($this->once())->method('assignCustomer')->with($customer); $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->will($this->returnValue($customer)); $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->will($this->returnValue($isLoggedIn)); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $this->checkoutSessionMock->expects($this->any())->method('getStepData')->will($this->returnValue($stepData)); if ($isSetStepDataCalled) { $this->checkoutSessionMock->expects($this->once())->method('setStepData')->with(key($stepData), 'allow', false); } else { $this->checkoutSessionMock->expects($this->never())->method('setStepData'); } $this->onepage->initCheckout(); }
/** * @magentoAppIsolation enabled * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testInitCheckoutLoggedIn() { $this->_model->saveBilling($this->_getCustomerData(), null); $this->_prepareQuote($this->_getQuote()); $customerIdFromFixture = 1; $emailFromFixture = '*****@*****.**'; /** @var $customerSession \Magento\Customer\Model\Session*/ $customerSession = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Session'); /** @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface */ $customerRepository = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerRepositoryInterface'); $customerData = $customerRepository->getById($customerIdFromFixture); $customerSession->setCustomerDataObject($customerData); $this->_model = Bootstrap::getObjectManager()->create('Magento\\Checkout\\Model\\Type\\Onepage', ['customerSession' => $customerSession]); $this->assertTrue($this->_model->getCheckout()->getSteps()['shipping']['allow']); $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']); $this->_model->initCheckout(); $this->assertFalse($this->_model->getCheckout()->getSteps()['shipping']['allow']); //When the user is logged in and for Step billing - allow is not reset to true $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']); $this->assertEquals($emailFromFixture, $this->_model->getQuote()->getCustomer()->getEmail()); }