CompositeTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Composite;
  8. class CompositeTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @dataProvider paymentMethodDataProvider
  12. * @param bool $expectation
  13. */
  14. public function testIsApplicable($expectation)
  15. {
  16. $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods(
  17. []
  18. )->getMock();
  19. $paymentMethod = $this->getMockBuilder(
  20. \Magento\Payment\Model\MethodInterface::class
  21. )->disableOriginalConstructor()->setMethods([])->getMock();
  22. $specification = $this->getMockBuilder(
  23. \Magento\Payment\Model\Checks\SpecificationInterface::class
  24. )->disableOriginalConstructor()->setMethods([])->getMock();
  25. $specification->expects($this->once())->method('isApplicable')->with($paymentMethod, $quote)->will(
  26. $this->returnValue($expectation)
  27. );
  28. $model = new Composite([$specification]);
  29. $this->assertEquals($expectation, $model->isApplicable($paymentMethod, $quote));
  30. }
  31. /**
  32. * @return array
  33. */
  34. public function paymentMethodDataProvider()
  35. {
  36. return [[true], [false]];
  37. }
  38. }