CalculatorTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\OfflineShipping\Test\Unit\Model\SalesRule;
  7. class CalculatorTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\OfflineShipping\Model\SalesRule\Calculator|\PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $_model;
  13. protected function setUp()
  14. {
  15. $this->_model = $this->createPartialMock(
  16. \Magento\OfflineShipping\Model\SalesRule\Calculator::class,
  17. ['_getRules', '__wakeup']
  18. );
  19. }
  20. /**
  21. * @return bool
  22. */
  23. public function testProcessFreeShipping()
  24. {
  25. $addressMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class)
  26. ->disableOriginalConstructor()
  27. ->getMock();
  28. $item = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, ['getAddress', '__wakeup']);
  29. $item->expects($this->once())->method('getAddress')->will($this->returnValue($addressMock));
  30. $this->_model->expects($this->once())
  31. ->method('_getRules')
  32. ->with($addressMock)
  33. ->will($this->returnValue([]));
  34. $this->assertInstanceOf(
  35. \Magento\OfflineShipping\Model\SalesRule\Calculator::class,
  36. $this->_model->processFreeShipping($item)
  37. );
  38. return true;
  39. }
  40. }