FormTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\PayflowExpress;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  8. use Magento\Paypal\Block\PayflowExpress\Form;
  9. use Magento\Paypal\Model\Config;
  10. class FormTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var Config|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $_paypalConfig;
  16. /**
  17. * @var Form
  18. */
  19. protected $_model;
  20. protected function setUp()
  21. {
  22. $this->_paypalConfig = $this->createMock(\Magento\Paypal\Model\Config::class);
  23. $this->_paypalConfig
  24. ->expects($this->once())
  25. ->method('setMethod')
  26. ->will($this->returnSelf());
  27. $paypalConfigFactory = $this->createPartialMock(\Magento\Paypal\Model\ConfigFactory::class, ['create']);
  28. $paypalConfigFactory->expects($this->once())
  29. ->method('create')
  30. ->will($this->returnValue($this->_paypalConfig));
  31. $mark = $this->createMock(\Magento\Framework\View\Element\Template::class);
  32. $mark->expects($this->once())
  33. ->method('setTemplate')
  34. ->will($this->returnSelf());
  35. $mark->expects($this->any())
  36. ->method('__call')
  37. ->will($this->returnSelf());
  38. $layout = $this->getMockForAbstractClass(
  39. \Magento\Framework\View\LayoutInterface::class
  40. );
  41. $layout->expects($this->once())
  42. ->method('createBlock')
  43. ->with(\Magento\Framework\View\Element\Template::class)
  44. ->will($this->returnValue($mark));
  45. $localeResolver = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class);
  46. $helper = new ObjectManager($this);
  47. $this->_model = $helper->getObject(
  48. \Magento\Paypal\Block\PayflowExpress\Form::class,
  49. [
  50. 'paypalConfigFactory' => $paypalConfigFactory,
  51. 'layout' => $layout,
  52. 'localeResolver' => $localeResolver
  53. ]
  54. );
  55. }
  56. public function testGetBillingAgreementCode()
  57. {
  58. $this->assertFalse($this->_model->getBillingAgreementCode());
  59. }
  60. }