Exemplo n.º 1
0
 public function testGetMethodInstanceRequestedMethod()
 {
     $code = 'real_method';
     $this->info->setData('method', $code);
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($code)->will($this->returnValue($this->methodInstanceMock));
     $this->methodInstanceMock->expects($this->once())->method('setInfoInstance')->with($this->info);
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
     // as the method is already stored at Info, check that it's not initialized again
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
 }
Exemplo n.º 2
0
 public function testGetMethodInstanceRequestedMethod()
 {
     $code = 'unreal_method';
     $this->info->setData('method', $code);
     $methodInstance = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->disableOriginalConstructor()->setMethods(['setInfoInstance', 'getCode', 'getFormBlockType', 'getTitle'])->getMock();
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($code)->will($this->returnValue($methodInstance));
     $methodInstance->expects($this->once())->method('setInfoInstance')->with($this->info);
     $this->assertSame($methodInstance, $this->info->getMethodInstance());
     // as the method is already stored at Info, check that it's not initialized again
     $this->assertSame($methodInstance, $this->info->getMethodInstance());
 }
Exemplo n.º 3
0
 /**
  * Retrieve payment method model object
  *
  * @return \Magento\Payment\Model\MethodInterface
  */
 public function getMethodInstance()
 {
     $method = parent::getMethodInstance();
     $method->setStore($this->getQuote()->getStore()->getStoreId());
     return $method;
 }
Exemplo n.º 4
0
 /**
  * Retrieve payment information block
  *
  * @param Info $info
  * @return Template
  */
 public function getInfoBlock(Info $info)
 {
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     $block = $this->_layout->createBlock($blockType);
     $block->setInfo($info);
     return $block;
 }
Exemplo n.º 5
0
 /**
  * Retrieve payment information block
  *
  * @param Info $info
  * @param \Magento\Framework\View\LayoutInterface $layout
  * @return Template
  */
 public function getInfoBlock(Info $info, LayoutInterface $layout = null)
 {
     $layout = $layout ?: $this->_layout;
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     $block = $layout->createBlock($blockType);
     $block->setInfo($info);
     return $block;
 }