QuoteSetupTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Test\Unit\Setup;
  7. use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  9. /**
  10. * Test for Quote module setup model.
  11. *
  12. * @package Magento\Quote\Test\Unit\Setup
  13. */
  14. class QuoteSetupTest extends \PHPUnit\Framework\TestCase
  15. {
  16. /**
  17. * @var \Magento\Quote\Setup\QuoteSetup
  18. */
  19. private $model;
  20. /**
  21. * @var ObjectManagerHelper
  22. */
  23. private $objectManagerHelper;
  24. /**
  25. * @var \Magento\Framework\Setup\ModuleDataSetupInterface|\PHPUnit_Framework_MockObject_MockObject
  26. */
  27. private $moduleDataSetupMock;
  28. /**
  29. * @var \Magento\Eav\Model\Entity\Setup\Context|\PHPUnit_Framework_MockObject_MockObject
  30. */
  31. private $contextMock;
  32. /**
  33. * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
  34. */
  35. private $cacheMock;
  36. /**
  37. * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
  38. */
  39. private $collectionFactoryMock;
  40. /**
  41. * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  42. */
  43. private $scopeConfigMock;
  44. protected function setUp()
  45. {
  46. $this->moduleDataSetupMock = $this->getMockBuilder(\Magento\Framework\Setup\ModuleDataSetupInterface::class)
  47. ->getMockForAbstractClass();
  48. $this->contextMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Setup\Context::class)
  49. ->disableOriginalConstructor()
  50. ->getMock();
  51. $this->cacheMock = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class)
  52. ->getMockForAbstractClass();
  53. $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
  54. ->disableOriginalConstructor()
  55. ->getMock();
  56. $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
  57. ->getMockForAbstractClass();
  58. $this->objectManagerHelper = new ObjectManagerHelper($this);
  59. $this->model = $this->objectManagerHelper->getObject(
  60. \Magento\Quote\Setup\QuoteSetup::class,
  61. [
  62. 'setup' => $this->moduleDataSetupMock,
  63. 'context' => $this->contextMock,
  64. 'cache' => $this->cacheMock,
  65. 'attrGroupCollectionFactory' => $this->collectionFactoryMock,
  66. 'config' => $this->scopeConfigMock
  67. ]
  68. );
  69. }
  70. public function testGetConnection()
  71. {
  72. $this->moduleDataSetupMock->expects($this->once())
  73. ->method('getConnection')
  74. ->with('checkout');
  75. $this->model->getConnection();
  76. }
  77. }