@@ -13,22 +13,36 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract
13
13
/** @var \Magento\Integration\Model\Integration */
14
14
protected $ integration ;
15
15
16
- public function testConfigBasedIntegrationCreation ()
16
+
17
+ protected function setUp ()
17
18
{
18
19
$ 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
-
28
20
/** @var $integrationService \Magento\Integration\Service\V1\IntegrationInterface */
29
21
$ 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 ());
32
46
}
33
47
34
48
/**
@@ -39,21 +53,16 @@ public function testConfigBasedIntegrationCreation()
39
53
public function testGetServiceCall ()
40
54
{
41
55
$ this ->_markTestAsRestOnly ();
42
- $ version = 'V1 ' ;
43
- $ restResourcePath = "/ {$ version }/testmodule4/ " ;
44
-
45
56
$ itemId = 1 ;
46
57
$ name = 'Test ' ;
47
58
$ serviceInfo = [
48
59
'rest ' => [
49
- 'resourcePath ' => $ restResourcePath . $ itemId ,
60
+ 'resourcePath ' => ' /V1/testmodule4/ ' . $ itemId ,
50
61
'httpMethod ' => \Magento \Webapi \Model \Rest \Config::HTTP_METHOD_GET ,
51
62
],
52
63
];
53
64
$ item = $ this ->_webApiCall ($ serviceInfo , [], null , null , $ this ->integration );
54
65
$ this ->assertEquals ($ itemId , $ item ['entity_id ' ], 'id field returned incorrectly ' );
55
66
$ this ->assertEquals ($ name , $ item ['name ' ], 'name field returned incorrectly ' );
56
-
57
- OauthHelper::clearApiAccessCredentials ();
58
67
}
59
68
}
0 commit comments