IntegrationTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Model\ResourceModel;
  7. /**
  8. * Integration test for \Magento\Integration\Model\ResourceModel\Integration
  9. */
  10. class IntegrationTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Integration\Model\Integration
  14. */
  15. protected $integration;
  16. /**
  17. * @var \Magento\Integration\Model\Oauth\Consumer
  18. */
  19. protected $consumer;
  20. protected function setUp()
  21. {
  22. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  23. $this->consumer = $objectManager->create(\Magento\Integration\Model\Oauth\Consumer::class);
  24. $this->consumer->setData(
  25. [
  26. 'key' => md5(uniqid()),
  27. 'secret' => md5(uniqid()),
  28. 'callback_url' => 'http://example.com/callback',
  29. 'rejected_callback_url' => 'http://example.com/rejectedCallback'
  30. ]
  31. )->save();
  32. $this->integration = $objectManager->create(\Magento\Integration\Model\Integration::class);
  33. $this->integration->setName('Test Integration')
  34. ->setConsumerId($this->consumer->getId())
  35. ->setStatus(\Magento\Integration\Model\Integration::STATUS_ACTIVE)
  36. ->save();
  37. }
  38. public function testLoadActiveIntegrationByConsumerId()
  39. {
  40. $integration = $this->integration->getResource()->selectActiveIntegrationByConsumerId($this->consumer->getId());
  41. $this->assertEquals($this->integration->getId(), $integration['integration_id']);
  42. }
  43. }