Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RestrictAdminBillingAgreementUsageObserverTest.php
Go to the documentation of this file.
1 <?php
9 
11 
15 class RestrictAdminBillingAgreementUsageObserverTest extends \PHPUnit\Framework\TestCase
16 {
20  protected $_model;
21 
25  protected $_observer;
26 
30  protected $_event;
31 
35  protected $_authorization;
36 
37  protected function setUp()
38  {
39  $this->_event = new DataObject();
40 
41  $this->_observer = new \Magento\Framework\Event\Observer();
42  $this->_observer->setEvent($this->_event);
43 
44  $this->_authorization = $this->getMockForAbstractClass(\Magento\Framework\AuthorizationInterface::class);
45 
46  $this->_model = new \Magento\Paypal\Observer\RestrictAdminBillingAgreementUsageObserver($this->_authorization);
47  }
48 
53  {
54  return [
55  [new \stdClass(), false, true],
56  [
57  $this->getMockForAbstractClass(
58  \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::class,
59  [],
60  '',
61  false
62  ),
63  true,
64  true
65  ],
66  [
67  $this->getMockForAbstractClass(
68  \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::class,
69  [],
70  '',
71  false
72  ),
73  false,
74  false
75  ]
76  ];
77  }
78 
85  public function testExecute($methodInstance, $isAllowed, $isAvailable)
86  {
87  $this->_event->setMethodInstance($methodInstance);
88  $this->_authorization->expects(
89  $this->any()
90  )->method(
91  'isAllowed'
92  )->with(
93  'Magento_Paypal::use'
94  )->will(
95  $this->returnValue($isAllowed)
96  );
97  $result = new DataObject();
98  $result->setData('is_available', true);
99  $this->_event->setResult($result);
100  $this->_model->execute($this->_observer);
101  $this->assertEquals($isAvailable, $result->getData('is_available'));
102  }
103 }
return false
Definition: gallery.phtml:36
$isAllowed
Definition: get.php:20