ltsecurityinc安防产品在线商城代码
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
*/
|
||||
namespace Magento\Integration\Model\Config\Consolidated;
|
||||
|
||||
use Magento\Integration\Model\Config\Consolidated\Reader as ConfigReader;
|
||||
|
||||
/**
|
||||
* Integration config reader test.
|
||||
*/
|
||||
class ReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $fileResolverMock;
|
||||
|
||||
/** @var ConfigReader */
|
||||
protected $configReader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->fileResolverMock = $this->getMockBuilder(\Magento\Framework\Config\FileResolverInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([])
|
||||
->getMock();
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->configReader = $objectManager->create(
|
||||
\Magento\Integration\Model\Config\Consolidated\Reader::class,
|
||||
['fileResolver' => $this->fileResolverMock]
|
||||
);
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$configFiles = [
|
||||
file_get_contents(realpath(__DIR__ . '/_files/integrationA.xml')),
|
||||
file_get_contents(realpath(__DIR__ . '/_files/integrationB.xml'))
|
||||
];
|
||||
$this->fileResolverMock->expects($this->any())->method('get')->willReturn($configFiles);
|
||||
|
||||
$expectedResult = require __DIR__ . '/_files/integration.php';
|
||||
$this->assertEquals($expectedResult, $this->configReader->read(), 'Error happened during config reading.');
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
'TestIntegration1' => [
|
||||
'email' => 'test-integration1@example.com',
|
||||
'endpoint_url' => 'http://example.com/endpoint1',
|
||||
'identity_link_url' => 'http://www.example.com/identity1',
|
||||
'resource' => [
|
||||
'Magento_Backend::admin',
|
||||
'Magento_Customer::customer',
|
||||
'Magento_Customer::manage',
|
||||
'Magento_Sales::sales',
|
||||
'Magento_Sales::sales_operation',
|
||||
'Magento_Sales::sales_order',
|
||||
'Magento_Sales::actions',
|
||||
'Magento_Sales::capture',
|
||||
'Magento_Backend::marketing',
|
||||
'Magento_CatalogRule::promo',
|
||||
'Magento_SalesRule::quote'
|
||||
]
|
||||
],
|
||||
'TestIntegration2' => [
|
||||
'email' => 'test-integration2@example.com',
|
||||
'endpoint_url' => 'http://example.com/integration2',
|
||||
'identity_link_url' => 'http://www.example.com/identity2',
|
||||
'resource' => [
|
||||
'Magento_Backend::admin',
|
||||
'Magento_Sales::sales',
|
||||
'Magento_Sales::sales_operation',
|
||||
'Magento_Sales::sales_order',
|
||||
'Magento_Sales::actions',
|
||||
'Magento_Sales::capture',
|
||||
'Magento_Backend::stores',
|
||||
'Magento_Backend::stores_settings',
|
||||
'Magento_Config::config',
|
||||
'Magento_SalesRule::config_promo'
|
||||
]
|
||||
],
|
||||
'TestIntegration3' => [
|
||||
'email' => 'test-integration3@example.com',
|
||||
'resource' => [
|
||||
'Magento_Backend::admin',
|
||||
'Magento_Sales::sales',
|
||||
'Magento_Sales::sales_operation',
|
||||
'Magento_Sales::sales_order',
|
||||
'Magento_Sales::actions',
|
||||
'Magento_Sales::create',
|
||||
'Magento_Backend::marketing',
|
||||
'Magento_CatalogRule::promo',
|
||||
'Magento_SalesRule::quote'
|
||||
]
|
||||
]
|
||||
];
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Integration:etc/integration/integration.xsd">
|
||||
<integration name="TestIntegration1">
|
||||
<email>test-integration1@example.com</email>
|
||||
<endpoint_url>http://example.com/endpoint1</endpoint_url>
|
||||
<identity_link_url>http://www.example.com/identity1</identity_link_url>
|
||||
<resources>
|
||||
<resource name="Magento_Customer::manage" />
|
||||
<resource name="Magento_Sales::capture" />
|
||||
<resource name="Magento_SalesRule::quote" />
|
||||
</resources>
|
||||
</integration>
|
||||
<integration name="TestIntegration2">
|
||||
<email>test-integration2@example.com</email>
|
||||
<resources>
|
||||
<resource name="Magento_Sales::capture" />
|
||||
</resources>
|
||||
</integration>
|
||||
<integration name="TestIntegration3">
|
||||
<email>test-integration3@example.com</email>
|
||||
<resources>
|
||||
<resource name="Magento_Sales::create" />
|
||||
<resource name="Magento_SalesRule::quote" />
|
||||
</resources>
|
||||
</integration>
|
||||
</config>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Integration:etc/integration/integration_file.xsd">
|
||||
<integration name="TestIntegration2">
|
||||
<!--Extension of data provided in integrationA.xml-->
|
||||
<endpoint_url>http://example.com/integration2</endpoint_url>
|
||||
<identity_link_url>http://www.example.com/identity2</identity_link_url>
|
||||
<resources>
|
||||
<resource name="Magento_SalesRule::config_promo" />
|
||||
</resources>
|
||||
</integration>
|
||||
</config>
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
*/
|
||||
namespace Magento\Integration\Model\Config\Integration;
|
||||
|
||||
use Magento\Integration\Model\Config\Integration\Reader as ConfigReader;
|
||||
|
||||
/**
|
||||
* Integration API config reader test.
|
||||
*/
|
||||
class ReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $_fileResolverMock;
|
||||
|
||||
/** @var ConfigReader */
|
||||
protected $_configReader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->_fileResolverMock = $this->createMock(\Magento\Framework\Config\FileResolverInterface::class);
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->_configReader = $objectManager->create(
|
||||
\Magento\Integration\Model\Config\Integration\Reader::class,
|
||||
['fileResolver' => $this->_fileResolverMock]
|
||||
);
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$configFiles = [
|
||||
file_get_contents(realpath(__DIR__ . '/_files/apiA.xml')),
|
||||
file_get_contents(realpath(__DIR__ . '/_files/apiB.xml')),
|
||||
];
|
||||
$this->_fileResolverMock->expects($this->any())->method('get')->willReturn($configFiles);
|
||||
|
||||
$expectedResult = require __DIR__ . '/_files/api.php';
|
||||
$this->assertEquals($expectedResult, $this->_configReader->read(), 'Error happened during config reading.');
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
'TestIntegration1' => [
|
||||
'resource' => [
|
||||
'Magento_Customer::manage',
|
||||
'Magento_Customer::online',
|
||||
'Magento_Sales::capture',
|
||||
'Magento_SalesRule::quote',
|
||||
],
|
||||
],
|
||||
'TestIntegration2' => [
|
||||
'resource' => ['Magento_Catalog::product_read', 'Magento_SalesRule::config_promo'],
|
||||
],
|
||||
'TestIntegration3' => [
|
||||
'resource' => ['Magento_Catalog::product_read', 'Magento_Sales::create', 'Magento_SalesRule::quote'],
|
||||
]
|
||||
];
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<integrations>
|
||||
<integration name="TestIntegration1">
|
||||
<!-- List of API resources required by the integration. These are resource ids defined
|
||||
in etc/acl.xml of modules and subsequently mapped to web APIs in webapi.xml. -->
|
||||
<resources>
|
||||
<resource name="Magento_Customer::manage" />
|
||||
<resource name="Magento_Customer::online" />
|
||||
<resource name="Magento_Sales::capture" />
|
||||
<resource name="Magento_SalesRule::quote" />
|
||||
</resources>
|
||||
</integration>
|
||||
<integration name="TestIntegration2">
|
||||
<resources>
|
||||
<resource name="Magento_Catalog::product_read" />
|
||||
</resources>
|
||||
</integration>
|
||||
</integrations>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<integrations>
|
||||
<integration name="TestIntegration2">
|
||||
<resources>
|
||||
<!--Extension of resources list defined in apiA.xml-->
|
||||
<resource name="Magento_SalesRule::config_promo" />
|
||||
</resources>
|
||||
</integration>
|
||||
<integration name="TestIntegration3">
|
||||
<resources>
|
||||
<resource name="Magento_Catalog::product_read" />
|
||||
<resource name="Magento_Sales::create" />
|
||||
<resource name="Magento_SalesRule::quote" />
|
||||
</resources>
|
||||
</integration>
|
||||
</integrations>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
*/
|
||||
namespace Magento\Integration\Model\Config;
|
||||
|
||||
use Magento\Integration\Model\Config\Reader as ConfigReader;
|
||||
|
||||
/**
|
||||
* Integration config reader test.
|
||||
*/
|
||||
class ReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $_fileResolverMock;
|
||||
|
||||
/** @var ConfigReader */
|
||||
protected $_configReader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->_fileResolverMock = $this->createMock(\Magento\Framework\Config\FileResolverInterface::class);
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->_configReader = $objectManager->create(
|
||||
\Magento\Integration\Model\Config\Reader::class,
|
||||
['fileResolver' => $this->_fileResolverMock]
|
||||
);
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$configFiles = [
|
||||
file_get_contents(realpath(__DIR__ . '/_files/configA.xml')),
|
||||
file_get_contents(realpath(__DIR__ . '/_files/configB.xml')),
|
||||
];
|
||||
$this->_fileResolverMock->expects($this->any())->method('get')->willReturn($configFiles);
|
||||
|
||||
$expectedResult = require __DIR__ . '/_files/integration.php';
|
||||
$this->assertEquals($expectedResult, $this->_configReader->read(), 'Error happened during config reading.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<integrations>
|
||||
<integration name="TestIntegration1">
|
||||
<email>test-integration1@example.com</email>
|
||||
<endpoint_url>http://example.com/endpoint1</endpoint_url>
|
||||
<identity_link_url>http://www.example.com/identity1</identity_link_url>
|
||||
</integration>
|
||||
<integration name="TestIntegration2">
|
||||
<email>test-integration2@example.com</email>
|
||||
</integration>
|
||||
</integrations>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<integrations>
|
||||
<integration name="TestIntegration2">
|
||||
<!--Extension of data provided in integrationA.xml-->
|
||||
<endpoint_url>http://example.com/integration2</endpoint_url>
|
||||
<identity_link_url>http://www.example.com/identity2</identity_link_url>
|
||||
</integration>
|
||||
<integration name="TestIntegration3">
|
||||
<email>test-integration3@example.com</email>
|
||||
</integration>
|
||||
</integrations>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
'TestIntegration1' => [
|
||||
'email' => 'test-integration1@example.com',
|
||||
'endpoint_url' => 'http://example.com/endpoint1',
|
||||
'identity_link_url' => 'http://www.example.com/identity1',
|
||||
],
|
||||
'TestIntegration2' => [
|
||||
'email' => 'test-integration2@example.com',
|
||||
'endpoint_url' => 'http://example.com/integration2',
|
||||
'identity_link_url' => 'http://www.example.com/identity2',
|
||||
],
|
||||
'TestIntegration3' => ['email' => 'test-integration3@example.com']
|
||||
];
|
||||
Reference in New Issue
Block a user