CheckoutTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Multishipping\Controller;
  7. use \Magento\Multishipping\Model\Checkout\Type\Multishipping\State;
  8. /**
  9. * Test class for \Magento\Multishipping\Controller\Checkout
  10. *
  11. * @magentoAppArea frontend
  12. * @magentoDataFixture Magento/Sales/_files/quote.php
  13. * @magentoDataFixture Magento/Customer/_files/customer.php
  14. */
  15. class CheckoutTest extends \Magento\TestFramework\TestCase\AbstractController
  16. {
  17. /**
  18. * @var \Magento\Quote\Model\Quote
  19. */
  20. protected $quote;
  21. /**
  22. * @var \Magento\Checkout\Model\Session
  23. */
  24. protected $checkoutSession;
  25. /**
  26. * @inheritdoc
  27. */
  28. public function setUp()
  29. {
  30. parent::setUp();
  31. $this->quote = $this->_objectManager->create(\Magento\Quote\Model\Quote::class);
  32. $this->checkoutSession = $this->_objectManager->get(\Magento\Checkout\Model\Session::class);
  33. $this->quote->load('test01', 'reserved_order_id');
  34. $this->checkoutSession->setQuoteId($this->quote->getId());
  35. $this->checkoutSession->setCartWasUpdated(false);
  36. }
  37. /**
  38. * Covers \Magento\Multishipping\Block\Checkout\Payment\Info and \Magento\Multishipping\Block\Checkout\Overview
  39. *
  40. * @magentoConfigFixture current_store multishipping/options/checkout_multiple 1
  41. */
  42. public function testOverviewAction()
  43. {
  44. /** @var \Magento\Framework\Data\Form\FormKey $formKey */
  45. $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class);
  46. $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
  47. /** @var \Magento\Customer\Api\AccountManagementInterface $service */
  48. $service = $this->_objectManager->create(\Magento\Customer\Api\AccountManagementInterface::class);
  49. $customer = $service->authenticate('customer@example.com', 'password');
  50. /** @var \Magento\Customer\Model\Session $customerSession */
  51. $customerSession = $this->_objectManager->create(\Magento\Customer\Model\Session::class, [$logger]);
  52. $customerSession->setCustomerDataAsLoggedIn($customer);
  53. $this->checkoutSession->setCheckoutState(State::STEP_BILLING);
  54. $this->getRequest()->setPostValue('payment', ['method' => 'checkmo']);
  55. $this->dispatch('multishipping/checkout/overview');
  56. $html = $this->getResponse()->getBody();
  57. $this->assertContains('<div class="box box-billing-method">', $html);
  58. $this->assertContains('<div class="box box-shipping-method">', $html);
  59. $this->assertContains(
  60. '<dt class="title">' . $this->quote->getPayment()->getMethodInstance()->getTitle() . '</dt>',
  61. $html
  62. );
  63. $this->assertContains('<span class="price">$10.00</span>', $html);
  64. $this->assertContains('<input name="form_key" type="hidden" value="' . $formKey->getFormKey(), $html);
  65. }
  66. }