CanUseInternalTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Test\Unit\Model\Checks;
  7. use \Magento\Payment\Model\Checks\CanUseInternal;
  8. class CanUseInternalTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var CanUseInternal
  12. */
  13. protected $_model;
  14. protected function setUp()
  15. {
  16. $this->_model = new CanUseInternal();
  17. }
  18. /**
  19. * @dataProvider paymentMethodDataProvider
  20. * @param bool $expectation
  21. */
  22. public function testIsApplicable($expectation)
  23. {
  24. $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods(
  25. []
  26. )->getMock();
  27. $paymentMethod = $this->getMockBuilder(
  28. \Magento\Payment\Model\MethodInterface::class
  29. )->disableOriginalConstructor()->setMethods([])->getMock();
  30. $paymentMethod->expects($this->once())->method('canUseInternal')->will(
  31. $this->returnValue($expectation)
  32. );
  33. $this->assertEquals($expectation, $this->_model->isApplicable($paymentMethod, $quote));
  34. }
  35. /**
  36. * @return array
  37. */
  38. public function paymentMethodDataProvider()
  39. {
  40. return [[true], [false]];
  41. }
  42. }