SetupDeltaLogTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Migration\App;
  7. /**
  8. * Class ShellTest
  9. */
  10. class SetupDeltaLogTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @return void
  14. */
  15. public function testPerform()
  16. {
  17. /** @var \Migration\ResourceModel\Source|\PHPUnit_Framework_MockObject_MockObject $source */
  18. $source = $this->createMock(\Migration\ResourceModel\Source::class);
  19. /** @var \Migration\ResourceModel\Document|\PHPUnit_Framework_MockObject_MockObject $source */
  20. $document = $this->createMock(\Migration\ResourceModel\Document::class);
  21. $source->expects($this->any())
  22. ->method('getDocument')
  23. ->willReturn($document);
  24. $source->expects($this->exactly(4))
  25. ->method('createDelta')
  26. ->withConsecutive(
  27. ['orders', 'order_id'],
  28. ['invoices', 'invoice_id'],
  29. ['reports', 'report_id'],
  30. ['shipments', 'shipment_id']
  31. );
  32. /** @var \Migration\Reader\Groups|\PHPUnit_Framework_MockObject_MockObject $readerGroups */
  33. $readerGroups = $this->createMock(\Migration\Reader\Groups::class);
  34. $readerGroups->expects($this->any())
  35. ->method('getGroups')
  36. ->with()
  37. ->willReturn(
  38. [
  39. 'firstGroup' => ['orders' => 'order_id', 'invoices' => 'invoice_id'],
  40. 'secondGroup' => ['reports' => 'report_id', 'shipments' => 'shipment_id']
  41. ]
  42. );
  43. /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
  44. $groupsFactory = $this->createMock(\Migration\Reader\GroupsFactory::class);
  45. $groupsFactory->expects($this->any())->method('create')->with('delta_document_groups_file')
  46. ->willReturn($readerGroups);
  47. /** @var \Migration\App\ProgressBar\LogLevelProcessor|\PHPUnit_Framework_MockObject_MockObject $progress */
  48. $progress = $this->createMock(\Migration\App\ProgressBar\LogLevelProcessor::class);
  49. $progress->expects($this->once())
  50. ->method('start')
  51. ->with(4);
  52. $progress->expects($this->exactly(4))
  53. ->method('advance');
  54. $progress->expects($this->once())
  55. ->method('finish');
  56. /** @var \Migration\Logger\Logger|\PHPUnit_Framework_MockObject_MockObject $logger */
  57. $logger = $this->createMock(\Migration\Logger\Logger::class);
  58. $deltaLog = new SetupDeltaLog($source, $groupsFactory, $progress, $logger);
  59. $this->assertTrue($deltaLog->perform());
  60. }
  61. }