Skip to content

Commit ff76fe8

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-33455-Cover-Config-Based-Integration-Creation' into develop
Conflicts: dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php
2 parents 91bd4c2 + 7e326de commit ff76fe8

File tree

14 files changed

+162
-20
lines changed

14 files changed

+162
-20
lines changed

app/code/Magento/Integration/Model/Integration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* @method \string getEmail()
1414
* @method Integration setEmail(\string $email)
1515
* @method Integration setStatus(\int $value)
16-
* @method \int getType()
17-
* @method Integration setType(\int $value)
16+
* @method \int getSetupType()
17+
* @method Integration setSetupType(\int $value)
1818
* @method Integration setConsumerId(\string $consumerId)
1919
* @method \string getConsumerId()
2020
* @method \string getEndpoint()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "magento/module-test-module-integration-from-config",
3+
"description": "test integration create from config",
4+
"require": {
5+
"php": "~5.5.0|~5.6.0",
6+
"magento/framework": "0.42.0-beta8",
7+
"magento/module-integration": "0.42.0-beta8",
8+
"magento/magento-composer-installer": "*"
9+
},
10+
"type": "magento2-module",
11+
"version": "1.0",
12+
"extra": {
13+
"map": [
14+
[
15+
"*",
16+
"Magento/TestModuleIntegrationFromConfig"
17+
]
18+
]
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
/** @var \Magento\Integration\Model\Resource\Setup $this */
7+
$this->initIntegrationProcessing(['Test Integration1']);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9+
<type name="Magento\Framework\Module\Updater\SetupFactory">
10+
<arguments>
11+
<argument name="resourceTypes" xsi:type="array">
12+
<item name="testmoduleintegrationfromconfig_setup" xsi:type="string">Magento\Integration\Model\Resource\Setup</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<integrations>
9+
<integration name="Test Integration1">
10+
<email>test-integration@magento.com</email>
11+
<endpoint_url>http://example.com/endpoint1</endpoint_url>
12+
</integration>
13+
</integrations>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9+
<module name="Magento_TestModuleIntegrationFromConfig" schema_version="0.0.1" active="true">
10+
</module>
11+
</config>

dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\TestFramework\Helper\Bootstrap;
1212
use OAuth\Common\Consumer\Credentials;
1313
use Zend\Stdlib\Exception\LogicException;
14+
use Magento\Integration\Model\Integration;
1415

1516
class OauthHelper
1617
{
@@ -93,6 +94,7 @@ public static function getAccessToken()
9394
* Create an access token, tied to integration which has permissions to all API resources in the system.
9495
*
9596
* @param array $resources list of resources to grant to the integration
97+
* @param \Magento\Integration\Model\Integration|null $integrationModel
9698
* @return array
9799
* <pre>
98100
* array (
@@ -104,10 +106,10 @@ public static function getAccessToken()
104106
* </pre>
105107
* @throws LogicException
106108
*/
107-
public static function getApiAccessCredentials($resources = null)
109+
public static function getApiAccessCredentials($resources = null, Integration $integrationModel = null)
108110
{
109111
if (!self::$_apiCredentials) {
110-
$integration = self::_createIntegration($resources);
112+
$integration = is_null($integrationModel) ? self::_createIntegration($resources) : $integrationModel;
111113
$objectManager = Bootstrap::getObjectManager();
112114
/** @var \Magento\Integration\Service\V1\Oauth $oauthService */
113115
$oauthService = $objectManager->get('Magento\Integration\Service\V1\Oauth');

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Rest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\TestFramework\Helper\Bootstrap;
1212
use Magento\Framework\Webapi\Rest\Request;
13+
use Magento\TestFramework\Authentication\OauthHelper;
1314

1415
class Rest implements \Magento\TestFramework\TestCase\Webapi\AdapterInterface
1516
{
@@ -64,13 +65,13 @@ public function __construct()
6465
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6566
* @SuppressWarnings(PHPMD.NPathComplexity)
6667
*/
67-
public function call($serviceInfo, $arguments = [], $storeCode = null)
68+
public function call($serviceInfo, $arguments = [], $storeCode = null, $integration = null)
6869
{
6970
$storeCode = !is_null($storeCode) ? (string)$storeCode : $this->defaultStoreCode;
7071
$resourcePath = '/' . $storeCode . $this->_getRestResourcePath($serviceInfo);
7172
$httpMethod = $this->_getRestHttpMethod($serviceInfo);
7273
//Get a valid token
73-
$accessCredentials = \Magento\TestFramework\Authentication\OauthHelper::getApiAccessCredentials();
74+
$accessCredentials = OauthHelper::getApiAccessCredentials(null, $integration);
7475
/** @var $oAuthClient \Magento\TestFramework\Authentication\Rest\OauthClient */
7576
$oAuthClient = $accessCredentials['oauth_client'];
7677
$urlFormEncoded = false;

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/Adapter/Soap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct()
4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function call($serviceInfo, $arguments = [], $storeCode = null)
50+
public function call($serviceInfo, $arguments = [], $storeCode = null, $integration = null)
5151
{
5252
$soapOperation = $this->_getSoapOperation($serviceInfo);
5353
$arguments = $this->_converter->convertKeysToCamelCase($arguments);

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/Webapi/AdapterInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ interface AdapterInterface
3333
* </pre>
3434
* @param array $arguments
3535
* @param string|null $storeCode if store code not provided, default store code will be used
36+
* @param \Magento\Integration\Model\Integration|null $integration
3637
* @return array|string|int|float|bool
3738
*/
38-
public function call($serviceInfo, $arguments = [], $storeCode = null);
39+
public function call($serviceInfo, $arguments = [], $storeCode = null, $integration = null);
3940
}

0 commit comments

Comments
 (0)