public function testGetConfigWithEmptyCustomer()
 {
     $customerId = 0;
     $expected = ['payment' => ['paypalBillingAgreement' => ['agreements' => [], 'transportName' => AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID]]];
     $this->currentCustomerMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->agreementFactoryMock->expects($this->never())->method('create');
     $this->assertEquals($expected, $this->configProvider->getConfig());
 }
 /**
  * @param int $count
  * @dataProvider aroundIsApplicableDataProvider
  */
 public function testAroundIsApplicable($count)
 {
     $paymentMethod = $this->getPaymentMethod('paypal_billing_agreement');
     $quote = $this->getQuote(1);
     $proceed = $this->getProceedClosure(true, $paymentMethod, $quote);
     $agreementCollection = $this->getMock('Magento\\Paypal\\Model\\Resource\\Billing\\Agreement\\Collection', [], [], '', false);
     $agreementCollection->expects($this->once())->method('count')->will($this->returnValue($count));
     $agreement = $this->getMock('Magento\\Paypal\\Model\\Billing\\Agreement', [], [], '', false);
     $agreement->expects($this->once())->method('getAvailableCustomerBillingAgreements')->with(1)->will($this->returnValue($agreementCollection));
     $this->agreementFactory->expects($this->once())->method('create')->will($this->returnValue($agreement));
     $this->assertEquals($count > 0, $this->callAroundIsApplicable($proceed, $paymentMethod, $quote));
 }
 public function testAssignData()
 {
     $baId = '1678235';
     $customerId = 67;
     $referenceId = '1234124';
     $data = new DataObject([PaymentInterface::KEY_ADDITIONAL_DATA => [AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID => $baId]]);
     $paymentInfo = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock();
     $quote = $this->getMockBuilder(Quote::class)->disableOriginalConstructor()->setMethods(['__wakeup', 'getCustomerId'])->getMock();
     $this->payment->setInfoInstance($paymentInfo);
     $agreementModel = $this->getMockBuilder(Agreement::class)->disableOriginalConstructor()->setMethods(['__wakeup', 'load', 'getCustomerId', 'getId', 'getReferenceId'])->getMock();
     $this->agreementFactory->expects(static::once())->method('create')->willReturn($agreementModel);
     $paymentInfo->expects(static::once())->method('getQuote')->willReturn($quote);
     $agreementModel->expects(static::once())->method('load')->with($baId);
     $agreementModel->expects(static::once())->method('getId')->willReturn($baId);
     $agreementModel->expects(static::atLeastOnce())->method('getCustomerId')->willReturn($customerId);
     $agreementModel->expects(static::atLeastOnce())->method('getReferenceId')->willReturn($referenceId);
     $quote->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $paymentInfo->expects(static::exactly(2))->method('setAdditionalInformation')->willReturnMap([AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID, $baId, AbstractAgreement::PAYMENT_INFO_REFERENCE_ID, $referenceId]);
     $this->payment->assignData($data);
 }