Ejemplo n.º 1
0
 /**
  * Prepare children blocks
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     /**
      * Create child blocks for payment methods forms
      */
     foreach ($this->getMethods() as $method) {
         $this->setChild('payment.method.' . $method->getCode(), $this->_paymentHelper->getMethodFormBlock($method, $this->_layout));
     }
     return parent::_prepareLayout();
 }
Ejemplo n.º 2
0
 public function testGetMethodFormBlock()
 {
     list($blockType, $methodCode) = ['method_block_type', 'method_code'];
     $methodMock = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->getMockForAbstractClass();
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->disableOriginalConstructor()->setMethods([])->getMock();
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\BlockInterface')->disableOriginalConstructor()->setMethods(['setMethod', 'toHtml'])->getMock();
     $methodMock->expects($this->once())->method('getFormBlockType')->willReturn($blockType);
     $methodMock->expects($this->once())->method('getCode')->willReturn($methodCode);
     $layoutMock->expects($this->once())->method('createBlock')->with($blockType, $methodCode)->willReturn($blockMock);
     $blockMock->expects($this->once())->method('setMethod')->with($methodMock);
     $this->assertSame($blockMock, $this->helper->getMethodFormBlock($methodMock, $layoutMock));
 }