|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2015 Magento. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace Magento\Integration\Model; |
| 7 | + |
| 8 | +use Magento\TestFramework\Helper\Bootstrap; |
| 9 | + |
| 10 | +class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract |
| 11 | +{ |
| 12 | + /** @var \Magento\Integration\Model\Integration */ |
| 13 | + protected $integration; |
| 14 | + |
| 15 | + public function testConfigBasedIntegrationCreation() |
| 16 | + { |
| 17 | + $objectManager = Bootstrap::getObjectManager(); |
| 18 | + |
| 19 | + /** @var \Magento\Integration\Model\Integration $integrationModel */ |
| 20 | + $integrationModel = $objectManager->get('Magento\Integration\Model\Integration'); |
| 21 | + $integrationModel->loadByConsumerId(1); |
| 22 | + $this->assertEquals('test-integration@magento.com', $integrationModel->getEmail()); |
| 23 | + $this->assertEquals('http://example.com/endpoint1', $integrationModel->getEndpoint()); |
| 24 | + $this->assertEquals('Test Integration1', $integrationModel->getName()); |
| 25 | + $this->assertEquals(Integration::TYPE_CONFIG, $integrationModel->getSetupType()); |
| 26 | + |
| 27 | + /** @var $integrationService \Magento\Integration\Service\V1\IntegrationInterface */ |
| 28 | + $integrationService = $objectManager->get('Magento\Integration\Service\V1\IntegrationInterface'); |
| 29 | + $this->integration = $integrationService->findByName('Test Integration1'); |
| 30 | + $this->integration->setStatus(Integration::STATUS_ACTIVE)->save(); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Test simple request data |
| 35 | + * |
| 36 | + * @depends testConfigBasedIntegrationCreation |
| 37 | + */ |
| 38 | + public function testGetServiceCall() |
| 39 | + { |
| 40 | + $this->_markTestAsRestOnly(); |
| 41 | + $version = 'V1'; |
| 42 | + $restResourcePath = "/{$version}/testmodule4/"; |
| 43 | + |
| 44 | + $itemId = 1; |
| 45 | + $name = 'Test'; |
| 46 | + $serviceInfo = [ |
| 47 | + 'rest' => [ |
| 48 | + 'resourcePath' => $restResourcePath . $itemId, |
| 49 | + 'httpMethod' => \Magento\Webapi\Model\Rest\Config::HTTP_METHOD_GET, |
| 50 | + ], |
| 51 | + ]; |
| 52 | + $item = $this->_webApiCall($serviceInfo, [], null, null, $this->integration); |
| 53 | + $this->assertEquals($itemId, $item['entity_id'], 'id field returned incorrectly'); |
| 54 | + $this->assertEquals($name, $item['name'], 'name field returned incorrectly'); |
| 55 | + } |
| 56 | +} |
0 commit comments