Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrdersUpdaterTest.php
Go to the documentation of this file.
1 <?php
7 
8 class OrdersUpdaterTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
18  protected $_registry;
19 
24 
25  protected function setUp()
26  {
27  $this->_registry = $this->createMock(\Magento\Framework\Registry::class);
28  $this->_agreementResource = $this->createMock(\Magento\Paypal\Model\ResourceModel\Billing\Agreement::class);
29 
30  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
31  $this->_model = $helper->getObject(
32  \Magento\Paypal\Model\Billing\Agreement\OrdersUpdater::class,
33  ['coreRegistry' => $this->_registry, 'agreementResource' => $this->_agreementResource]
34  );
35  }
36 
37  public function testUpdate()
38  {
39  $agreement = $this->createMock(\Magento\Paypal\Model\Billing\Agreement::class);
40  $argument = $this->createMock(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
41 
42  $this->_registry->expects(
43  $this->once()
44  )->method(
45  'registry'
46  )->with(
47  'current_billing_agreement'
48  )->will(
49  $this->returnValue($agreement)
50  );
51 
52  $agreement->expects($this->once())->method('getId')->will($this->returnValue('agreement id'));
53  $this->_agreementResource->expects(
54  $this->once()
55  )->method(
56  'addOrdersFilter'
57  )->with(
58  $this->identicalTo($argument),
59  'agreement id'
60  );
61 
62  $this->assertSame($argument, $this->_model->update($argument));
63  }
64 
69  {
70  $this->_registry->expects(
71  $this->once()
72  )->method(
73  'registry'
74  )->with(
75  'current_billing_agreement'
76  )->will(
77  $this->returnValue(null)
78  );
79 
80  $this->_model->update('any argument');
81  }
82 }
$helper
Definition: iframe.phtml:13