ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,141 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Directory\Api;
use Magento\TestFramework\TestCase\WebapiAbstract;
class CountryInformationAcquirerTest extends WebapiAbstract
{
const SERVICE_NAME = 'directoryCountryInformationAcquirerV1';
const RESOURCE_COUNTRIES_PATH = '/V1/directory/countries';
const RESOURCE_COUNTRY = 'US';
const SERVICE_VERSION = 'V1';
const STORE_CODE_FROM_FIXTURE = 'fixturestore';
/**
* @magentoApiDataFixture Magento/Store/_files/core_fixturestore.php
*/
public function testGetCountries()
{
/** @var $store \Magento\Store\Model\Group */
$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class);
$store->load(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.');
$result = $this->getCountriesInfo(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('id', $result[0]);
$this->assertArrayHasKey('two_letter_abbreviation', $result[0]);
$this->assertArrayHasKey('three_letter_abbreviation', $result[0]);
$this->assertArrayHasKey('full_name_locale', $result[0]);
$this->assertArrayHasKey('full_name_english', $result[0]);
$this->assertSame('AD', $result[0]['id']);
$this->assertSame('AD', $result[0]['two_letter_abbreviation']);
$this->assertSame('AND', $result[0]['three_letter_abbreviation']);
$this->assertSame('Andorra', $result[0]['full_name_english']);
}
/**
* @magentoApiDataFixture Magento/Store/_files/core_fixturestore.php
*/
public function testGetCountry()
{
/** @var $store \Magento\Store\Model\Group */
$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class);
$store->load(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.');
$result = $this->getCountryInfo(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('two_letter_abbreviation', $result);
$this->assertArrayHasKey('three_letter_abbreviation', $result);
$this->assertArrayHasKey('full_name_locale', $result);
$this->assertArrayHasKey('full_name_english', $result);
$this->assertArrayHasKey('available_regions', $result);
$this->assertSame('US', $result['id']);
$this->assertSame('US', $result['two_letter_abbreviation']);
$this->assertSame('USA', $result['three_letter_abbreviation']);
$this->assertSame('United States', $result['full_name_english']);
}
/**
* Retrieve existing country information for the store
*
* @param string $storeCode
* @return \Magento\Directory\Api\Data\CountryInformationInterface
*/
protected function getCountriesInfo($storeCode = 'default')
{
$serviceInfo = [
'rest' => [
'resourcePath' => self::RESOURCE_COUNTRIES_PATH,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'GetCountriesInfo',
],
];
$requestData = ['storeId' => $storeCode];
return $this->_webApiCall($serviceInfo, $requestData);
}
/**
* Retrieve existing country information for the store
*
* @param string $storeCode
* @return \Magento\Directory\Api\Data\CountryInformationInterface
*/
protected function getCountryInfo($storeCode = 'default')
{
$serviceInfo = [
'rest' => [
'resourcePath' => self::RESOURCE_COUNTRIES_PATH . '/' . self::RESOURCE_COUNTRY,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'GetCountryInfo',
],
];
$requestData = ['storeId' => $storeCode, 'countryId' => self::RESOURCE_COUNTRY];
return $this->_webApiCall($serviceInfo, $requestData);
}
/**
* Remove test store
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
/** @var \Magento\Framework\Registry $registry */
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Registry::class);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
/** @var $store \Magento\Store\Model\Store */
$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class);
$store->load(self::STORE_CODE_FROM_FIXTURE);
if ($store->getId()) {
$store->delete();
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
}
}
@@ -0,0 +1,123 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Directory\Api;
use Magento\TestFramework\TestCase\WebapiAbstract;
class CurrencyInformationAcquirerTest extends WebapiAbstract
{
const SERVICE_NAME = 'directoryCurrencyInformationAcquirerV1';
const RESOURCE_PATH = '/V1/directory/currency';
const SERVICE_VERSION = 'V1';
const STORE_CODE_FROM_FIXTURE = 'fixturestore';
/**
* @magentoApiDataFixture Magento/Store/_files/core_fixturestore.php
*/
public function testGet()
{
/** @var $store \Magento\Store\Model\Group */
$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class);
$store->load(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($store->getId(), 'Precondition failed: fixture store was not created.');
$result = $this->getCurrencyInfo(self::STORE_CODE_FROM_FIXTURE);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('base_currency_code', $result);
$this->assertArrayHasKey('base_currency_symbol', $result);
$this->assertArrayHasKey('default_display_currency_code', $result);
$this->assertArrayHasKey('default_display_currency_symbol', $result);
$this->assertArrayHasKey('available_currency_codes', $result);
$this->assertArrayHasKey('exchange_rates', $result);
$this->assertTrue(
in_array($result['base_currency_code'], $result['available_currency_codes']),
'Missing the base currency code in the array of all available codes'
);
$this->assertTrue(
in_array($result['default_display_currency_code'], $result['available_currency_codes']),
'Missing the default display currency code in the array of all available codes'
);
// ensure the base currency is listed in the array of exchange rates, and has a rate of 1 (no conversion)
$this->verifyExchangeRate($result['base_currency_code'], 1.0, $result['exchange_rates']);
}
/**
* @param string $code
* @param float $rate
* @param array $exchangeRates
*/
protected function verifyExchangeRate($code, $rate, $exchangeRates)
{
$this->assertNotEmpty($exchangeRates, 'Expected to have non-empty structure of exchange rates');
$foundCode = false;
$foundRate = false;
foreach ($exchangeRates as $exchangeRate) {
if ($code == $exchangeRate['currency_to']) {
$foundCode = true;
if ($rate == $exchangeRate['rate']) {
$foundRate = true;
}
}
}
$this->assertTrue($foundCode, 'Did not find currency code in the exchange rates: ' . $code);
$this->assertTrue($foundRate, 'Did not find the expected rate for currency ' . $code . ': ' . $rate);
}
/**
* Retrieve existing currency information for the store
*
* @param string $storeCode
* @return \Magento\Directory\Api\Data\CurrencyInformationInterface
*/
protected function getCurrencyInfo($storeCode = 'default')
{
$serviceInfo = [
'rest' => [
'resourcePath' => self::RESOURCE_PATH,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'GetCurrencyInfo',
],
];
$requestData = ['storeId' => $storeCode];
return $this->_webApiCall($serviceInfo, $requestData);
}
/**
* Remove test store
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
/** @var \Magento\Framework\Registry $registry */
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Registry::class);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
/** @var $store \Magento\Store\Model\Store */
$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create(\Magento\Store\Model\Store::class);
$store->load(self::STORE_CODE_FROM_FIXTURE);
if ($store->getId()) {
$store->delete();
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
}
}