CheckmoTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\OfflinePayments\Test\Unit\Model;
  7. class CheckmoTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\OfflinePayments\Model\Checkmo
  11. */
  12. protected $_object;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $_scopeConfig;
  17. protected function setUp()
  18. {
  19. $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  20. $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
  21. $paymentDataMock = $this->createMock(\Magento\Payment\Helper\Data::class);
  22. $this->_scopeConfig = $this->createPartialMock(
  23. \Magento\Framework\App\Config\ScopeConfigInterface::class,
  24. ['getValue', 'isSetFlag']
  25. );
  26. $this->_object = $objectManagerHelper->getObject(
  27. \Magento\OfflinePayments\Model\Checkmo::class,
  28. [
  29. 'eventManager' => $eventManager,
  30. 'paymentData' => $paymentDataMock,
  31. 'scopeConfig' => $this->_scopeConfig,
  32. ]
  33. );
  34. }
  35. public function testGetPayableTo()
  36. {
  37. $this->_object->setStore(1);
  38. $this->_scopeConfig->expects($this->once())
  39. ->method('getValue')
  40. ->with('payment/checkmo/payable_to', 'store', 1)
  41. ->willReturn('payable');
  42. $this->assertEquals('payable', $this->_object->getPayableTo());
  43. }
  44. public function testGetMailingAddress()
  45. {
  46. $this->_object->setStore(1);
  47. $this->_scopeConfig->expects($this->once())
  48. ->method('getValue')
  49. ->with('payment/checkmo/mailing_address', 'store', 1)
  50. ->willReturn('blah@blah.com');
  51. $this->assertEquals('blah@blah.com', $this->_object->getMailingAddress());
  52. }
  53. }