CollectionUpdaterTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Test\Unit\Model\Grid\Child;
  7. class CollectionUpdaterTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Sales\Model\Grid\Child\CollectionUpdater
  11. */
  12. protected $collectionUpdater;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $registryMock;
  17. protected function setUp()
  18. {
  19. $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
  20. $this->collectionUpdater = new \Magento\Sales\Model\Grid\Child\CollectionUpdater(
  21. $this->registryMock
  22. );
  23. }
  24. public function testUpdateIfOrderExists()
  25. {
  26. $collectionMock = $this->createMock(
  27. \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection::class
  28. );
  29. $transactionMock = $this->createMock(\Magento\Sales\Model\Order\Payment\Transaction::class);
  30. $this->registryMock
  31. ->expects($this->once())
  32. ->method('registry')
  33. ->with('current_transaction')
  34. ->will($this->returnValue($transactionMock));
  35. $transactionMock->expects($this->once())->method('getId')->will($this->returnValue('transactionId'));
  36. $collectionMock->expects($this->once())->method('addParentIdFilter')->will($this->returnSelf());
  37. $this->assertEquals($collectionMock, $this->collectionUpdater->update($collectionMock));
  38. }
  39. }