SourceDestinationTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Migration\ResourceModel;
  7. /**
  8. * ResourceModel source and destination test class
  9. */
  10. class SourceDestinationTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Migration\ResourceModel\Source $source
  14. */
  15. protected $source;
  16. /**
  17. * @var \Migration\ResourceModel\Destination $destination
  18. */
  19. protected $destination;
  20. /**
  21. * @return void
  22. */
  23. protected function setUp()
  24. {
  25. $helper = \Migration\TestFramework\Helper::getInstance();
  26. $objectManager = $helper->getObjectManager();
  27. $objectManager->get(\Migration\Config::class)
  28. ->init(dirname(__DIR__) . '/_files/' . $helper->getFixturePrefix() . 'config.xml');
  29. $this->source = $objectManager->get(\Migration\ResourceModel\Source::class);
  30. $this->destination = $objectManager->get(\Migration\ResourceModel\Destination::class);
  31. }
  32. /**
  33. * @return void
  34. */
  35. public function testGetRecordsCount()
  36. {
  37. $sourceCount = $this->source->getRecordsCount('table_with_data');
  38. $destinationCount = $this->destination->getRecordsCount('table_without_data');
  39. $this->assertEquals(7, $sourceCount);
  40. $this->assertEquals(0, $destinationCount);
  41. }
  42. /**
  43. * @return void
  44. */
  45. public function testGetFields()
  46. {
  47. $sourceStruct = $this->source->getDocument('table_with_data')->getStructure()->getFields();
  48. $destStruct = $this->destination->getDocument('table_without_data')->getStructure()->getFields();
  49. $this->assertEquals(array_keys($sourceStruct), array_keys($destStruct));
  50. }
  51. }