ShippingTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Test\Unit\Block\Checkout;
  7. class ShippingTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Tax\Block\Checkout\Shipping
  11. */
  12. protected $model;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $quoteMock;
  17. protected function setUp()
  18. {
  19. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  20. $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
  21. $checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class);
  22. $checkoutSession->expects($this->any())->method('getQuote')->willReturn($this->quoteMock);
  23. $this->model = $objectManager->getObject(
  24. \Magento\Tax\Block\Checkout\Shipping::class,
  25. ['checkoutSession' => $checkoutSession]
  26. );
  27. }
  28. /**
  29. * @param string $shippingMethod
  30. * @param bool $expectedResult
  31. * @dataProvider displayShippingDataProvider
  32. */
  33. public function testDisplayShipping($shippingMethod, $expectedResult)
  34. {
  35. $addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, ['getShippingMethod']);
  36. $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($addressMock);
  37. $addressMock->expects($this->once())->method('getShippingMethod')->willReturn($shippingMethod);
  38. $this->assertEquals($expectedResult, $this->model->displayShipping());
  39. }
  40. /**
  41. * @return array
  42. */
  43. public function displayShippingDataProvider()
  44. {
  45. return [
  46. ["flatrate_flatrate", true],
  47. [null, false]
  48. ];
  49. }
  50. }