ViewTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Paypal\Test\Unit\Block\Billing\Agreement;
  7. /**
  8. * Class ViewTest
  9. * @package Magento\Paypal\Block\Billing\Agreement
  10. */
  11. class ViewTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory | \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $orderCollectionFactory;
  17. /**
  18. * @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject
  19. */
  20. protected $orderConfig;
  21. /**
  22. * @var View
  23. */
  24. protected $block;
  25. protected function setUp()
  26. {
  27. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  28. $this->orderCollectionFactory = $this->createPartialMock(
  29. \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class,
  30. ['create']
  31. );
  32. $this->orderConfig = $this->createMock(\Magento\Sales\Model\Order\Config::class);
  33. $this->block = $objectManager->getObject(
  34. \Magento\Paypal\Block\Billing\Agreement\View::class,
  35. [
  36. 'orderCollectionFactory' => $this->orderCollectionFactory,
  37. 'orderConfig' => $this->orderConfig,
  38. ]
  39. );
  40. }
  41. public function testGetRelatedOrders()
  42. {
  43. $visibleStatuses = [];
  44. $orderCollection = $this->createPartialMock(
  45. \Magento\Sales\Model\ResourceModel\Order\Collection::class,
  46. ['addFieldToSelect', 'addFieldToFilter', 'setOrder']
  47. );
  48. $orderCollection->expects($this->at(0))
  49. ->method('addFieldToSelect')
  50. ->will($this->returnValue($orderCollection));
  51. $orderCollection->expects($this->at(1))
  52. ->method('addFieldToFilter')
  53. ->will($this->returnValue($orderCollection));
  54. $orderCollection->expects($this->at(2))
  55. ->method('addFieldToFilter')
  56. ->with('status', ['in' => $visibleStatuses])
  57. ->will($this->returnValue($orderCollection));
  58. $orderCollection->expects($this->at(3))
  59. ->method('setOrder')
  60. ->will($this->returnValue($orderCollection));
  61. $this->orderCollectionFactory->expects($this->once())
  62. ->method('create')
  63. ->will($this->returnValue($orderCollection));
  64. $this->orderConfig->expects($this->once())
  65. ->method('getVisibleOnFrontStatuses')
  66. ->will($this->returnValue($visibleStatuses));
  67. $this->block->getRelatedOrders();
  68. }
  69. }