Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SpecificationFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Payment\Model\Checks\SpecificationFactory;
10 
11 class SpecificationFactoryTest extends \PHPUnit\Framework\TestCase
12 {
16  const SPECIFICATION_KEY = 'specification';
17 
21  protected $_compositeFactory;
22 
23  protected function setUp()
24  {
25  $this->_compositeFactory = $this->getMockBuilder(
26  \Magento\Payment\Model\Checks\CompositeFactory::class
27  )->disableOriginalConstructor()->setMethods(['create'])->getMock();
28  }
29 
30  public function testCreate()
31  {
32  $specification = $this->getMockBuilder(
33  \Magento\Payment\Model\Checks\SpecificationInterface::class
34  )->disableOriginalConstructor()->setMethods([])->getMock();
35  $specificationMapping = [self::SPECIFICATION_KEY => $specification];
36 
37  $expectedComposite = $this->getMockBuilder(
38  \Magento\Payment\Model\Checks\Composite::class
39  )->disableOriginalConstructor()->setMethods([])->getMock();
40  $modelFactory = new SpecificationFactory($this->_compositeFactory, $specificationMapping);
41  $this->_compositeFactory->expects($this->once())->method('create')->with(
42  ['list' => $specificationMapping]
43  )->will($this->returnValue($expectedComposite));
44 
45  $this->assertEquals($expectedComposite, $modelFactory->create([self::SPECIFICATION_KEY]));
46  }
47 }