Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CollectionUpdaterTest.php
Go to the documentation of this file.
1 <?php
8 
9 class CollectionUpdaterTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $collectionUpdater;
15 
19  protected $registryMock;
20 
21  protected function setUp()
22  {
23  $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
24 
25  $this->collectionUpdater = new \Magento\Sales\Model\Grid\Child\CollectionUpdater(
26  $this->registryMock
27  );
28  }
29 
30  public function testUpdateIfOrderExists()
31  {
32  $collectionMock = $this->createMock(
33  \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class
34  );
35  $transactionMock = $this->createMock(\Magento\Sales\Model\Order\Payment\Transaction::class);
36  $this->registryMock
37  ->expects($this->once())
38  ->method('registry')
39  ->with('current_transaction')
40  ->will($this->returnValue($transactionMock));
41  $transactionMock->expects($this->once())->method('getId')->will($this->returnValue('transactionId'));
42  $collectionMock->expects($this->once())->method('addParentIdFilter')->will($this->returnSelf());
43  $this->assertEquals($collectionMock, $this->collectionUpdater->update($collectionMock));
44  }
45 }