DocumentTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Migration\ResourceModel;
  7. class DocumentTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Migration\ResourceModel\Record\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $recordCollectionFactory;
  13. /**
  14. * @var \Migration\ResourceModel\Structure|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $structure;
  17. /**
  18. * @var \Migration\ResourceModel\Document
  19. */
  20. protected $document;
  21. /**
  22. * @return void
  23. */
  24. protected function setUp()
  25. {
  26. $this->structure = $this->createMock(\Migration\ResourceModel\Structure::class);
  27. $this->recordCollectionFactory = $this->getMockBuilder(\Migration\ResourceModel\Record\CollectionFactory::class)
  28. ->disableOriginalConstructor()
  29. ->setMethods(['create'])
  30. ->getMock();
  31. $this->document = new \Migration\ResourceModel\Document(
  32. $this->recordCollectionFactory,
  33. $this->structure,
  34. 'test_document'
  35. );
  36. }
  37. /**
  38. * @return void
  39. */
  40. public function testGetRecords()
  41. {
  42. $recordCollection = $this->createMock(\Migration\ResourceModel\Record\Collection::class);
  43. $this->recordCollectionFactory->expects($this->atLeastOnce())
  44. ->method('create')
  45. ->with($this->equalTo([
  46. 'structure' => $this->structure,
  47. 'documentName' => 'test_document',
  48. ]))
  49. ->will($this->returnValue($recordCollection));
  50. $this->assertSame($recordCollection, $this->document->getRecords());
  51. }
  52. /**
  53. * @return void
  54. */
  55. public function testGetName()
  56. {
  57. $this->assertEquals('test_document', $this->document->getName());
  58. }
  59. /**
  60. * @return void
  61. */
  62. public function testGetStructure()
  63. {
  64. $this->assertSame($this->structure, $this->document->getStructure());
  65. }
  66. }