/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Specification must implement SpecificationInterface */ public function testWrongTypeException() { $className = 'WrongClass'; $methodMock = $this->getMock($className); $this->objectManagerMock->expects($this->once())->method('get')->with($className)->will($this->returnValue($methodMock)); $this->factory->create($className); }
/** * @param bool $firstSpecificationResult * @param bool $secondSpecificationResult * @param bool $compositeResult * @dataProvider compositeDataProvider */ public function testComposite($firstSpecificationResult, $secondSpecificationResult, $compositeResult) { $method = 'method-name'; $specificationFirst = $this->getMock('Magento\\Payment\\Model\\Method\\SpecificationInterface'); $specificationFirst->expects($this->once())->method('isSatisfiedBy')->with($method)->will($this->returnValue($firstSpecificationResult)); $specificationSecond = $this->getMock('Magento\\Payment\\Model\\Method\\SpecificationInterface'); $specificationSecond->expects($this->any())->method('isSatisfiedBy')->with($method)->will($this->returnValue($secondSpecificationResult)); $this->factoryMock->expects($this->at(0))->method('create')->with('SpecificationFirst')->will($this->returnValue($specificationFirst)); $this->factoryMock->expects($this->at(1))->method('create')->with('SpecificationSecond')->will($this->returnValue($specificationSecond)); $composite = $this->createComposite(['SpecificationFirst', 'SpecificationSecond']); $this->assertEquals($compositeResult, $composite->isSatisfiedBy($method), 'Composite specification is not satisfied by payment method'); }
/** * Construct * * @param Factory $factory * @param array $specifications */ public function __construct(Factory $factory, $specifications = array()) { foreach ($specifications as $specification) { $this->specifications[] = $factory->create($specification); } }