IntegrationTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Test\Unit\Model\ResourceModel;
  7. /**
  8. * Unit test for \Magento\Integration\Model\ResourceModel\Integration
  9. */
  10. class IntegrationTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $selectMock;
  16. /**
  17. * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
  18. */
  19. protected $connectionMock;
  20. /**
  21. * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
  22. */
  23. protected $resourceMock;
  24. /**
  25. * @var \Magento\Framework\Model\ResourceModel\Db\Context|\PHPUnit_Framework_MockObject_MockObject
  26. */
  27. protected $contextMock;
  28. /**
  29. * @var \Magento\Integration\Model\ResourceModel\Integration
  30. */
  31. protected $integrationResourceModel;
  32. protected function setUp()
  33. {
  34. $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
  35. $this->selectMock->expects($this->any())->method('from')->will($this->returnValue($this->selectMock));
  36. $this->selectMock->expects($this->any())->method('where')->will($this->returnValue($this->selectMock));
  37. $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
  38. $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock);
  39. $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
  40. $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
  41. $this->contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class);
  42. $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
  43. $this->integrationResourceModel = new \Magento\Integration\Model\ResourceModel\Integration($this->contextMock);
  44. }
  45. public function testSelectActiveIntegrationByConsumerId()
  46. {
  47. $consumerId = 1;
  48. $this->connectionMock->expects($this->once())->method('fetchRow')->with($this->selectMock);
  49. $this->integrationResourceModel->selectActiveIntegrationByConsumerId($consumerId);
  50. }
  51. }