SpecificationFactoryTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\SpecificationFactory;
  8. class SpecificationFactoryTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * Specification key
  12. */
  13. const SPECIFICATION_KEY = 'specification';
  14. /**
  15. * @var \Magento\Payment\Model\Checks\CompositeFactory | \PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $_compositeFactory;
  18. protected function setUp()
  19. {
  20. $this->_compositeFactory = $this->getMockBuilder(
  21. \Magento\Payment\Model\Checks\CompositeFactory::class
  22. )->disableOriginalConstructor()->setMethods(['create'])->getMock();
  23. }
  24. public function testCreate()
  25. {
  26. $specification = $this->getMockBuilder(
  27. \Magento\Payment\Model\Checks\SpecificationInterface::class
  28. )->disableOriginalConstructor()->setMethods([])->getMock();
  29. $specificationMapping = [self::SPECIFICATION_KEY => $specification];
  30. $expectedComposite = $this->getMockBuilder(
  31. \Magento\Payment\Model\Checks\Composite::class
  32. )->disableOriginalConstructor()->setMethods([])->getMock();
  33. $modelFactory = new SpecificationFactory($this->_compositeFactory, $specificationMapping);
  34. $this->_compositeFactory->expects($this->once())->method('create')->with(
  35. ['list' => $specificationMapping]
  36. )->will($this->returnValue($expectedComposite));
  37. $this->assertEquals($expectedComposite, $modelFactory->create([self::SPECIFICATION_KEY]));
  38. }
  39. }