GuestCartTotalRepositoryTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Quote\Test\Unit\Model\GuestCart;
  8. class GuestCartTotalRepositoryTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Quote\Model\GuestCart\GuestCartTotalRepository
  12. */
  13. protected $model;
  14. /**
  15. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  16. */
  17. protected $objectManager;
  18. /**
  19. * @var \PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $cartTotalRepository;
  22. /**
  23. * @var \PHPUnit_Framework_MockObject_MockObject
  24. */
  25. protected $quoteIdMaskFactoryMock;
  26. /**
  27. * @var \PHPUnit_Framework_MockObject_MockObject
  28. */
  29. protected $quoteIdMaskMock;
  30. /**
  31. * @var string
  32. */
  33. protected $maskedCartId;
  34. /**
  35. * @var int
  36. */
  37. protected $cartId;
  38. protected function setUp()
  39. {
  40. $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  41. $this->cartTotalRepository = $this->getMockBuilder(\Magento\Quote\Api\CartTotalRepositoryInterface::class)
  42. ->disableOriginalConstructor()
  43. ->getMock();
  44. $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73';
  45. $this->cartId = 123;
  46. $guestCartTestHelper = new GuestCartTestHelper($this);
  47. list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask(
  48. $this->maskedCartId,
  49. $this->cartId
  50. );
  51. $this->model = $this->objectManager->getObject(
  52. \Magento\Quote\Model\GuestCart\GuestCartTotalRepository::class,
  53. [
  54. 'cartTotalRepository' => $this->cartTotalRepository,
  55. 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock,
  56. ]
  57. );
  58. }
  59. public function testGetTotals()
  60. {
  61. $retValue = 'retValue';
  62. $this->cartTotalRepository->expects($this->once())
  63. ->method('get')
  64. ->with($this->cartId)
  65. ->will($this->returnValue($retValue));
  66. $this->assertSame($retValue, $this->model->get($this->maskedCartId));
  67. }
  68. }