Ejemplo n.º 1
0
 /**
  * @param bool $result
  *
  * @dataProvider dataProviderForTestIsAvailable
  */
 public function testIsAvailable($result)
 {
     $storeId = 15;
     $this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with('payment/' . Stub::STUB_CODE . '/active', ScopeInterface::SCOPE_STORE, $storeId)->willReturn($result);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->equalTo('payment_method_is_active'), $this->countOf(3));
     $this->assertEquals($result, $this->payment->isAvailable($this->quoteMock));
 }
Ejemplo n.º 2
0
 public function testGetShippingAddress()
 {
     /** @var AddressAdapterInterface $addressAdapterMock */
     $addressAdapterMock = $this->getMockBuilder('Magento\\Payment\\Gateway\\Data\\AddressAdapterInterface')->getMockForAbstractClass();
     /** @var \Magento\Quote\Api\Data\AddressInterface $quoteAddressMock */
     $quoteAddressMock = $this->getMockBuilder('Magento\\Quote\\Api\\Data\\AddressInterface')->getMockForAbstractClass();
     $this->addressAdapterFactoryMock->expects($this->once())->method('create')->with(['address' => $quoteAddressMock])->willReturn($addressAdapterMock);
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($quoteAddressMock);
     $this->assertSame($addressAdapterMock, $this->model->getShippingAddress());
 }
Ejemplo n.º 3
0
 public function testSave()
 {
     $this->quoteRepositoryMock->expects($this->any())->method('get')->willReturn($this->quoteMock);
     $this->quoteMock->expects($this->once())->method('getItemsCount')->willReturn(1);
     $this->quoteMock->expects($this->once())->method('getIsVirtual')->willReturn(false);
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
     $this->messageMock->expects($this->any())->method('setCustomerId');
     $this->messageMock->expects($this->any())->method('setGiftMessageId');
     $this->cacheMock->expects($this->once())->method('save');
     $this->assertTrue($this->cartRepository->save($this->cartId, $this->messageMock));
 }
Ejemplo n.º 4
0
 public function testSave()
 {
     $this->quoteRepositoryMock->expects($this->any())->method('get')->willReturn($this->quoteMock);
     $this->quoteItemMock->expects($this->once())->method('getItemId')->willReturn($this->itemId);
     $this->quoteItemMock->expects($this->once())->method('getProductType')->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE);
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
     $this->messageMock->expects($this->any())->method('setCustomerId');
     $this->messageMock->expects($this->any())->method('setGiftMessageId');
     $this->cacheMock->expects($this->once())->method('save');
     $this->assertTrue($this->itemRepository->save($this->cartId, $this->messageMock, $this->itemId));
 }