コード例 #1
0
ファイル: ReadService.php プロジェクト: zhangjiachao/magento2
 /**
  * {@inheritdoc}
  */
 public function getList($cartId)
 {
     $output = [];
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $this->quoteRepository->get($cartId);
     foreach ($this->methodList->getAvailableMethods($quote) as $method) {
         $output[] = $this->paymentMethodConverter->toDataObject($method);
     }
     return $output;
 }
コード例 #2
0
 public function testGetAvailableMethods()
 {
     $storeId = 1;
     $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId));
     $quoteMock->expects($this->atLeastOnce())->method('getPayment')->will($this->returnValue($this->getMock('\\Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false)));
     $methodMock = $this->getMock('Magento\\Payment\\Model\\Method\\AbstractMethod', [], [], '', false);
     $compositeMock = $this->getMock('\\Magento\\Payment\\Model\\Checks\\Composite', [], [], '', false);
     $compositeMock->expects($this->atLeastOnce())->method('isApplicable')->with($methodMock, $quoteMock)->will($this->returnValue(true));
     $this->specificationFactoryMock->expects($this->atLeastOnce())->method('create')->will($this->returnValue($compositeMock));
     $storeMethods = [$methodMock];
     $this->paymentHelperMock->expects($this->once())->method('getStoreMethods')->with($storeId, $quoteMock)->will($this->returnValue($storeMethods));
     $methodMock->expects($this->atLeastOnce())->method('setInfoInstance')->with($this->getMock('\\Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false))->will($this->returnSelf());
     $this->assertEquals([$methodMock], $this->methodList->getAvailableMethods($quoteMock));
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function getList($cartId)
 {
     $output = [];
     /** @var \Magento\Sales\Model\Quote $quote */
     $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
     foreach ($this->methodList->getAvailableMethods($quote) as $method) {
         $output[] = $this->paymentMethodConverter->toDataObject($method);
     }
     return $output;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function getList($cartId)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->quoteRepository->get($cartId);
     return $this->methodList->getAvailableMethods($quote);
 }