Skip to content

Commit 1d72d50

Browse files
committed
MAGETWO-33455: Cover Config-based Integration Creation with Test
- fix test
1 parent aa01c1d commit 1d72d50

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,36 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract
1313
/** @var \Magento\Integration\Model\Integration */
1414
protected $integration;
1515

16-
public function testConfigBasedIntegrationCreation()
16+
17+
protected function setUp()
1718
{
1819
$objectManager = Bootstrap::getObjectManager();
19-
20-
/** @var \Magento\Integration\Model\Integration $integrationModel */
21-
$integrationModel = $objectManager->get('Magento\Integration\Model\Integration');
22-
$integrationModel->loadByConsumerId(1);
23-
$this->assertEquals('test-integration@magento.com', $integrationModel->getEmail());
24-
$this->assertEquals('http://example.com/endpoint1', $integrationModel->getEndpoint());
25-
$this->assertEquals('Test Integration1', $integrationModel->getName());
26-
$this->assertEquals(Integration::TYPE_CONFIG, $integrationModel->getSetupType());
27-
2820
/** @var $integrationService \Magento\Integration\Service\V1\IntegrationInterface */
2921
$integrationService = $objectManager->get('Magento\Integration\Service\V1\IntegrationInterface');
30-
$this->integration = $integrationService->findByName('Test Integration1');
31-
$this->integration->setStatus(Integration::STATUS_ACTIVE)->save();
22+
23+
$params = [
24+
'all_resources' => false,
25+
'integration_id' => 1,
26+
'status' => Integration::STATUS_ACTIVE,
27+
'name' => 'Test Integration1'
28+
];
29+
$this->integration = $integrationService->update($params);
30+
parent::setUp();
31+
}
32+
33+
protected function tearDown()
34+
{
35+
unset($this->integration);
36+
OauthHelper::clearApiAccessCredentials();
37+
parent::tearDown();
38+
}
39+
40+
public function testConfigBasedIntegrationCreation()
41+
{
42+
$this->assertEquals('test-integration@magento.com', $this->integration->getEmail());
43+
$this->assertEquals('http://example.com/endpoint1', $this->integration->getEndpoint());
44+
$this->assertEquals('Test Integration1', $this->integration->getName());
45+
$this->assertEquals(Integration::TYPE_CONFIG, $this->integration->getSetupType());
3246
}
3347

3448
/**
@@ -39,21 +53,16 @@ public function testConfigBasedIntegrationCreation()
3953
public function testGetServiceCall()
4054
{
4155
$this->_markTestAsRestOnly();
42-
$version = 'V1';
43-
$restResourcePath = "/{$version}/testmodule4/";
44-
4556
$itemId = 1;
4657
$name = 'Test';
4758
$serviceInfo = [
4859
'rest' => [
49-
'resourcePath' => $restResourcePath . $itemId,
60+
'resourcePath' => '/V1/testmodule4/' . $itemId,
5061
'httpMethod' => \Magento\Webapi\Model\Rest\Config::HTTP_METHOD_GET,
5162
],
5263
];
5364
$item = $this->_webApiCall($serviceInfo, [], null, null, $this->integration);
5465
$this->assertEquals($itemId, $item['entity_id'], 'id field returned incorrectly');
5566
$this->assertEquals($name, $item['name'], 'name field returned incorrectly');
56-
57-
OauthHelper::clearApiAccessCredentials();
5867
}
5968
}

0 commit comments

Comments
 (0)