_compositeFactory = $this->getMockBuilder( \Magento\Payment\Model\Checks\CompositeFactory::class )->disableOriginalConstructor()->setMethods(['create'])->getMock(); } public function testCreate() { $specification = $this->getMockBuilder( \Magento\Payment\Model\Checks\SpecificationInterface::class )->disableOriginalConstructor()->setMethods([])->getMock(); $specificationMapping = [self::SPECIFICATION_KEY => $specification]; $expectedComposite = $this->getMockBuilder( \Magento\Payment\Model\Checks\Composite::class )->disableOriginalConstructor()->setMethods([])->getMock(); $modelFactory = new SpecificationFactory($this->_compositeFactory, $specificationMapping); $this->_compositeFactory->expects($this->once())->method('create')->with( ['list' => $specificationMapping] )->will($this->returnValue($expectedComposite)); $this->assertEquals($expectedComposite, $modelFactory->create([self::SPECIFICATION_KEY])); } }