示例#1
0
 public function testBuild()
 {
     $expectedRequest = ['user' => 'Mrs G. Crump', 'url' => 'https://url.in', 'amount' => 10.0, 'currecy' => 'pound', 'address' => '46 Egernon Crescent', 'item' => 'gas cooker', 'quantity' => 1];
     $customerBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $productBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $magentoBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $customerBuilder->expects(static::once())->method('build')->willReturn(['user' => 'Mrs G. Crump', 'address' => '46 Egernon Crescent']);
     $productBuilder->expects(static::once())->method('build')->willReturn(['amount' => 10.0, 'currecy' => 'pound', 'item' => 'gas cooker', 'quantity' => 1]);
     $magentoBuilder->expects(static::once())->method('build')->willReturn(['url' => 'https://url.in']);
     $tMap = $this->getMockBuilder('Magento\\Framework\\ObjectManager\\TMap')->disableOriginalConstructor()->getMock();
     $tMap->expects(static::once())->method('getIterator')->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder]));
     $builder = new BuilderComposite($tMap);
     static::assertEquals($expectedRequest, $builder->build([]));
 }
 /**
  * @param array $expected
  * @covers \Magento\Payment\Gateway\Request\BuilderComposite::build
  * @dataProvider buildDataProvider
  */
 public function testBuild(array $expected)
 {
     $tMapFactory = $this->getMockBuilder('Magento\\Framework\\ObjectManager\\TMapFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $tMap = $this->getMockBuilder('Magento\\Framework\\ObjectManager\\TMap')->disableOriginalConstructor()->getMock();
     $customerBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $productBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $magentoBuilder = $this->getMockBuilder('Magento\\Payment\\Gateway\\Request\\BuilderInterface')->getMockForAbstractClass();
     $customerBuilder->expects(static::once())->method('build')->willReturn(['user' => $expected['user'], 'address' => $expected['address']]);
     $productBuilder->expects(static::once())->method('build')->willReturn(['amount' => $expected['amount'], 'currency' => $expected['currency'], 'item' => $expected['item'], 'quantity' => $expected['quantity'], 'options' => ['product' => $expected['options']['product']]]);
     $magentoBuilder->expects(static::once())->method('build')->willReturn(['url' => $expected['url'], 'options' => ['magento' => $expected['options']['magento']]]);
     $tMapFactory->expects(static::once())->method('create')->with(['array' => ['customer' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface', 'product' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface', 'magento' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface'], 'type' => BuilderInterface::class])->willReturn($tMap);
     $tMap->expects(static::once())->method('getIterator')->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder]));
     $builder = new BuilderComposite($tMapFactory, ['customer' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface', 'product' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface', 'magento' => 'Magento\\Payment\\Gateway\\Request\\BuilderInterface']);
     static::assertEquals($expected, $builder->build([]));
 }