/**
  * @covers \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testVaultCaptureExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::VAULT_CAPTURE)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testCloneExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)->setMethods(['getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
     $paymentExtension->expects(static::once())->method('getVaultPaymentToken')->willReturn(null);
     $this->payment->expects(static::once())->method('getExtensionAttributes')->willReturn($paymentExtension);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::CLONE_TRANSACTION)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
 /**
  * @param int $size
  * @param string $command
  * @covers       \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  * @dataProvider captureDataProvider
  */
 public function testCaptureExecute($size, $command)
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->filterBuilder->expects(static::exactly(2))->method('setField')->willReturnSelf();
     $this->filterBuilder->expects(static::exactly(2))->method('setValue')->willReturnSelf();
     $searchCriteria = new SearchCriteria();
     $this->searchCriteriaBuilder->expects(static::once())->method('addFilters')->willReturnSelf();
     $this->searchCriteriaBuilder->expects(static::once())->method('create')->willReturn($searchCriteria);
     $this->transactionRepository->expects(static::once())->method('getList')->with($searchCriteria)->willReturnSelf();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn($size);
     $this->commandPool->expects(static::once())->method('get')->with($command)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }