GroupsTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Migration\Reader;
  7. /**
  8. * Class GroupTest
  9. */
  10. class GroupsTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var Groups
  14. */
  15. protected $groups;
  16. /**
  17. * @var \Magento\Framework\App\Arguments\ValidationState|\PHPUnit_Framework_MockObject_MockObject
  18. */
  19. protected $validationState;
  20. /**
  21. * @return void
  22. */
  23. public function setUp()
  24. {
  25. $this->validationState = $this->getMockBuilder(\Magento\Framework\App\Arguments\ValidationState::class)
  26. ->disableOriginalConstructor()
  27. ->setMethods(['isValidationRequired'])
  28. ->getMock();
  29. $this->validationState->expects($this->any())->method('isValidationRequired')->willReturn(true);
  30. }
  31. /**
  32. * @return void
  33. */
  34. public function testGetGroupAttributes()
  35. {
  36. $groupsFile = 'tests/unit/testsuite/Migration/_files/eav-attribute-groups.xml';
  37. $attributes = [
  38. 'url_key' => ['catalog_product', 'catalog_category'],
  39. 'msrp_enabled' => ['catalog_product']
  40. ];
  41. $groups = new Groups($this->validationState, $groupsFile);
  42. $this->assertEquals($attributes, $groups->getGroup('ignore'));
  43. }
  44. /**
  45. * @return void
  46. */
  47. public function testGetGroupDocuments()
  48. {
  49. $groupsFile = 'tests/unit/testsuite/Migration/_files/eav-document-groups.xml';
  50. $documents = [
  51. 'catalog_eav_attribute' => 'attribute_id',
  52. 'customer_eav_attribute' => 'attribute_id',
  53. 'eav_entity_type' => 'entity_type_id'
  54. ];
  55. $groups = new Groups($this->validationState, $groupsFile);
  56. $this->assertEquals($documents, $groups->getGroup('mapped_documents'));
  57. }
  58. /**
  59. * @return void
  60. */
  61. public function testGetGroups()
  62. {
  63. $groupsFile = 'tests/unit/testsuite/Migration/_files/eav-document-groups.xml';
  64. $documents = [
  65. 'documents' => [
  66. 'eav_attribute_group' => '', 'eav_attribute_set' => ''
  67. ],
  68. 'mapped_documents' => [
  69. 'catalog_eav_attribute' => 'attribute_id',
  70. 'customer_eav_attribute' => 'attribute_id',
  71. 'eav_entity_type' => 'entity_type_id'
  72. ],
  73. 'documents_leftover_values' => [
  74. 'catalog_category_entity_datetime' => ''
  75. ],
  76. ];
  77. $groups = new Groups($this->validationState, $groupsFile);
  78. $this->assertEquals($documents, $groups->getGroups());
  79. }
  80. }