12 use Magento\Paypal\Model\ConfigFactory;
21 private $currentCustomer;
31 private $paypalConfig;
36 private $billingAgreement;
40 $this->paypalConfig = $this->createMock(Config::class);
42 ->expects($this->once())
44 ->will($this->returnSelf());
46 $this->paypalConfig->expects($this->once())
50 $paypalConfigFactory = $this->createPartialMock(ConfigFactory::class, [
'create']);
51 $paypalConfigFactory->expects($this->once())
53 ->will($this->returnValue($this->paypalConfig));
56 $this->currentCustomer = $this->createMock(CurrentCustomer::class);
57 $this->currentCustomer->expects($this->any())
58 ->method(
'getCustomerId')
61 $this->paypalData = $this->createMock(Data::class);
64 $this->billingAgreement =
$helper->getObject(
65 BillingAgreement::class,
67 'paypalConfigFactory' => $paypalConfigFactory,
68 'paypalData' => $this->paypalData,
69 'currentCustomer' => $this->currentCustomer
76 $this->paypalData->expects($this->once())
77 ->method(
'shouldAskToCreateBillingAgreement')
78 ->with($this->paypalConfig, $this->currentCustomer->getCustomerId())
81 $result = $this->billingAgreement->getSectionData();
83 $this->assertArrayHasKey(
'askToCreate',
$result);
84 $this->assertArrayHasKey(
'confirmUrl',
$result);
85 $this->assertArrayHasKey(
'confirmMessage',
$result);
86 $this->assertTrue(
$result[
'askToCreate']);
91 $this->paypalData->expects($this->once())
92 ->method(
'shouldAskToCreateBillingAgreement')
93 ->with($this->paypalConfig, $this->currentCustomer->getCustomerId())
96 $result = $this->billingAgreement->getSectionData();
testGetSectionDataNotNeedToCreateBillingAgreement()