ltsecurityinc安防产品在线商城代码
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model\Config\Backend\Admin;
|
||||
|
||||
use Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class RobotsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Config\Model\Config\Backend\Admin\Robots
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Filesystem\Directory\Read
|
||||
*/
|
||||
protected $rootDirectory;
|
||||
|
||||
/**
|
||||
* Initialize model
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->model = $objectManager->create(\Magento\Config\Model\Config\Backend\Admin\Robots::class);
|
||||
$this->model->setPath('design/search_engine_robots/custom_instructions');
|
||||
$this->model->afterLoad();
|
||||
|
||||
$this->rootDirectory = $objectManager->get(Filesystem::class)->getDirectoryRead(DirectoryList::PUB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that default value is empty when robots.txt not exists
|
||||
*
|
||||
* @magentoDataFixture Magento/Config/Model/_files/no_robots_txt.php
|
||||
*/
|
||||
public function testAfterLoadRobotsTxtNotExists()
|
||||
{
|
||||
$this->assertEmpty($this->model->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that default value equals to robots.txt content when it is available
|
||||
*
|
||||
* @magentoDataFixture Magento/Config/Model/_files/robots_txt.php
|
||||
*/
|
||||
public function testAfterLoadRobotsTxtExists()
|
||||
{
|
||||
$value = $this->model->getValue();
|
||||
$this->assertEquals('Sitemap: http://store.com/sitemap.xml', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check robots.txt file generated when robots.txt not exists
|
||||
*
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testAfterSaveFileNotExists()
|
||||
{
|
||||
$this->assertFalse($this->rootDirectory->isExist('robots.txt'), 'robots.txt exists');
|
||||
|
||||
$this->_modifyConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check robots.txt file changed when robots.txt exists
|
||||
*
|
||||
* @magentoDataFixture Magento/Config/Model/_files/robots_txt.php
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testAfterSaveFileExists()
|
||||
{
|
||||
$this->assertTrue($this->rootDirectory->isExist('robots.txt'), 'robots.txt not exists');
|
||||
|
||||
$this->_modifyConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify config value and check all changes were written into robots.txt
|
||||
*/
|
||||
protected function _modifyConfig()
|
||||
{
|
||||
$robotsTxt = "User-Agent: *\nDisallow: /checkout";
|
||||
$this->model->setValue($robotsTxt)->save();
|
||||
$file = $this->rootDirectory->getAbsolutePath('robots.txt');
|
||||
$this->assertStringEqualsFile($file, $robotsTxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove created robots.txt
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
require 'Magento/Config/Model/_files/no_robots_txt.php';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model\Config\Backend;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class BaseurlTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $value
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider validationDataProvider
|
||||
*/
|
||||
public function testValidation($path, $value)
|
||||
{
|
||||
/** @var $model \Magento\Config\Model\Config\Backend\Baseurl */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Config\Model\Config\Backend\Baseurl::class
|
||||
);
|
||||
$model->setPath($path)->setValue($value)->save();
|
||||
$this->assertNotEmpty((int)$model->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validationDataProvider()
|
||||
{
|
||||
$basePlaceholder = '{{base_url}}';
|
||||
$unsecurePlaceholder = '{{unsecure_base_url}}';
|
||||
$unsecureSuffix = '{{unsecure_base_url}}test/';
|
||||
$securePlaceholder = '{{secure_base_url}}';
|
||||
$secureSuffix = '{{secure_base_url}}test/';
|
||||
|
||||
return [
|
||||
['any/path', 'http://example.com/'],
|
||||
['any/path', 'http://example.com/uri/'],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $basePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $basePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $securePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $secureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $securePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $secureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $securePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $secureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $unsecureSuffix],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $value
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider validationExceptionDataProvider
|
||||
*/
|
||||
public function testValidationException($path, $value)
|
||||
{
|
||||
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
|
||||
|
||||
/** @var $model \Magento\Config\Model\Config\Backend\Baseurl */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Config\Model\Config\Backend\Baseurl::class
|
||||
);
|
||||
$model->setPath($path)->setValue($value)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validationExceptionDataProvider()
|
||||
{
|
||||
$baseSuffix = '{{base_url}}test/';
|
||||
$unsecurePlaceholder = '{{unsecure_base_url}}';
|
||||
$unsecureSuffix = '{{unsecure_base_url}}test/';
|
||||
$unsecureWrongSuffix = '{{unsecure_base_url}}test';
|
||||
$unsecureWrongDomainName = 'http://example.com_test/';
|
||||
$securePlaceholder = '{{secure_base_url}}';
|
||||
$secureSuffix = '{{secure_base_url}}test/';
|
||||
$secureWrongSuffix = '{{secure_base_url}}test';
|
||||
$secureWrongDomainName = 'https://example.com_test/';
|
||||
|
||||
return [
|
||||
['', 'not a valid URL'],
|
||||
['', 'example.com'],
|
||||
['', 'http://example.com'],
|
||||
['', 'http://example.com/uri'],
|
||||
['', $unsecureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $baseSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecurePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $baseSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, $unsecureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, $unsecureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $baseSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $secureSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $securePlaceholder],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $secureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, ''],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $baseSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $secureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $secureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $secureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $secureWrongDomainName],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $secureWrongSuffix],
|
||||
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, $secureWrongDomainName],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Config\Model\Config\Backend;
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class EncryptedTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testEncryptionSave()
|
||||
{
|
||||
$originalValue = '1Password';
|
||||
|
||||
/** @var $model \Magento\Config\Model\Config\Backend\Encrypted */
|
||||
$model = Bootstrap::getObjectManager()->create(\Magento\Config\Model\Config\Backend\Encrypted::class);
|
||||
$model->setPath('carriers/usps/password');
|
||||
$model->setScopeId(0);
|
||||
$model->setScope('default');
|
||||
$model->setScopeCode('');
|
||||
$model->setValue($originalValue);
|
||||
$model->save();
|
||||
|
||||
// Pass in the obscured value
|
||||
$model->setPath('carriers/usps/password');
|
||||
$model->setScopeId(0);
|
||||
$model->setScope('default');
|
||||
$model->setScopeCode('');
|
||||
$model->setValue('*****');
|
||||
$model->save();
|
||||
|
||||
//Verify original value is not changed for obscured value
|
||||
$value = $model->load($model->getId())->getValue();
|
||||
$this->assertEquals($originalValue, $value, 'Original value is not expected to change.');
|
||||
|
||||
// Verify if actual value is changed
|
||||
$changedValue = 'newPassword';
|
||||
|
||||
$model->setPath('carriers/usps/password');
|
||||
$model->setScopeId(0);
|
||||
$model->setScope('default');
|
||||
$model->setScopeCode('');
|
||||
$model->setValue($changedValue);
|
||||
$model->save();
|
||||
|
||||
//Verify original value is changed
|
||||
$value = $model->load($model->getId())->getValue();
|
||||
$this->assertEquals($changedValue, $value, 'Original value is expected to change.');
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model\Config\Backend\Image;
|
||||
|
||||
class AdapterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Config\Model\Config\Backend\Image\Adapter
|
||||
*/
|
||||
protected $_model = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Config\Model\Config\Backend\Image\Adapter::class
|
||||
);
|
||||
$this->_model->setPath('path');
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testExceptionSave()
|
||||
{
|
||||
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'The specified image adapter cannot be used because of: Image adapter for \'wrong\' is not setup.'
|
||||
);
|
||||
|
||||
$this->_model->setValue('wrong')->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testCorrectSave()
|
||||
{
|
||||
$this->_model->setValue(\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2)->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Config\Model\Config\Export;
|
||||
|
||||
use Magento\Config\Model\Config\TypePool;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CommentTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Comment
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->comment = Bootstrap::getObjectManager()->create(Comment::class);
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$sensitivePaths = $this->getSensitivePaths();
|
||||
$comments = $this->comment->get();
|
||||
|
||||
$missedPaths = [];
|
||||
foreach ($sensitivePaths as $sensitivePath) {
|
||||
if (stripos($comments, $sensitivePath) === false) {
|
||||
$missedPaths[] = $sensitivePath;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEmpty(
|
||||
$missedPaths,
|
||||
'Sensitive paths are missed: ' . implode(', ', $missedPaths)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve sensitive paths from class that is used to check is path sensitive.
|
||||
*
|
||||
* There is no public method to get this data.
|
||||
* It's why they are read using private method.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getSensitivePaths(): array
|
||||
{
|
||||
$typePool = Bootstrap::getObjectManager()->get(TypePool::class);
|
||||
$sensitivePathsReader = \Closure::bind(
|
||||
function () {
|
||||
return $this->getPathsByType(TypePool::TYPE_SENSITIVE);
|
||||
},
|
||||
$typePool,
|
||||
$typePool
|
||||
);
|
||||
|
||||
return $sensitivePathsReader();
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model\Config\Processor;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
|
||||
class EnvironmentPlaceholderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var EnvironmentPlaceholder
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $env = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->model = $this->objectManager->get(EnvironmentPlaceholder::class);
|
||||
$this->env = $_ENV;
|
||||
}
|
||||
|
||||
public function testProcess()
|
||||
{
|
||||
$_ENV = array_merge(
|
||||
$_ENV,
|
||||
[
|
||||
'CONFIG__DEFAULT__WEB__UNSECURE__BASE_URL' => 'http://expected.local',
|
||||
'CONFIG__TEST__TEST__DESIGN__HEADER__WELCOME' => 'Expected header',
|
||||
'TEST__TEST__WEB__SECURE__BASE_URL' => 'http://wrong_pattern.local',
|
||||
'CONFIG__DEFAULT__GENERAL__REGION__DISPLAY_ALL' => 1
|
||||
]
|
||||
);
|
||||
$expected = [
|
||||
'default' => [
|
||||
'web' => [
|
||||
'unsecure' => [
|
||||
'base_url' => 'http://expected.local'
|
||||
],
|
||||
'secure' => [
|
||||
'base_url' => 'https://original.local'
|
||||
]
|
||||
],
|
||||
'general' => [
|
||||
'region' => [
|
||||
'display_all' => 1
|
||||
],
|
||||
],
|
||||
],
|
||||
'test' => [
|
||||
'test' => [
|
||||
'design' => [
|
||||
'header' => [
|
||||
'welcome' => 'Expected header'
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
];
|
||||
$config = [
|
||||
'default' => [
|
||||
'web' => [
|
||||
'unsecure' => [
|
||||
'base_url' => 'http://original.local',
|
||||
],
|
||||
'secure' => [
|
||||
'base_url' => 'https://original.local'
|
||||
]
|
||||
]
|
||||
],
|
||||
'test' => [
|
||||
'test' => [
|
||||
'design' => [
|
||||
'header' => [
|
||||
'welcome' => 'Original header'
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->model->process($config)
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$_ENV = $this->env;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Config\Model\Config\Structure\Reader;
|
||||
|
||||
use Magento\Config\Model\Config\Structure\Converter;
|
||||
|
||||
/**
|
||||
* Class ConverterStub used for ReaderTest.
|
||||
*/
|
||||
class ConverterStub extends Converter
|
||||
{
|
||||
/**
|
||||
* Convert dom document wrapper.
|
||||
*
|
||||
* @param \DOMDocument $document
|
||||
* @return array|null
|
||||
*/
|
||||
public function getArrayData(\DOMDocument $document)
|
||||
{
|
||||
return $this->_convertDOMDocument($document);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert dom document.
|
||||
*
|
||||
* @param \DOMNode $source
|
||||
* @return array
|
||||
*/
|
||||
public function convert($source)
|
||||
{
|
||||
return $this->_convertDOMDocument($source);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Config\Model\Config\Structure\Reader;
|
||||
|
||||
use Magento\Config\Model\Config\Structure\Reader;
|
||||
|
||||
/**
|
||||
* Class ReaderStub used for testing protected Reader::_readFiles() method.
|
||||
*/
|
||||
class ReaderStub extends Reader
|
||||
{
|
||||
/**
|
||||
* Wrapper for protected Reader::_readFiles() method.
|
||||
*
|
||||
* @param array $fileList
|
||||
* @return array
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function readFiles(array $fileList)
|
||||
{
|
||||
return $this->_readFiles($fileList);
|
||||
}
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Config\Model\Config\Structure\Reader;
|
||||
|
||||
use Magento\Config\Model\Config\SchemaLocator;
|
||||
use Magento\Framework\App\Utility\Files;
|
||||
use Magento\Framework\Config\Dom;
|
||||
use Magento\Framework\Config\FileResolverInterface;
|
||||
use Magento\Framework\Config\ValidationStateInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\TemplateEngine\Xhtml\CompilerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* Class ReaderTest check Magento\Config\Model\Config\Structure\Reader::_readFiles() method.
|
||||
*/
|
||||
class ReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Test config location.
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const CONFIG = '/dev/tests/integration/testsuite/Magento/Config/Model/Config/Structure/Reader/_files/';
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var Files
|
||||
*/
|
||||
private $fileUtility;
|
||||
|
||||
/**
|
||||
* @var ValidationStateInterface
|
||||
*/
|
||||
private $validationStateMock;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Config\SchemaLocatorInterface
|
||||
*/
|
||||
private $schemaLocatorMock;
|
||||
|
||||
/**
|
||||
* @var FileResolverInterface
|
||||
*/
|
||||
private $fileResolverMock;
|
||||
|
||||
/**
|
||||
* @var ReaderStub
|
||||
*/
|
||||
private $reader;
|
||||
|
||||
/**
|
||||
* @var ConverterStub
|
||||
*/
|
||||
private $converter;
|
||||
|
||||
/**
|
||||
* @var CompilerInterface|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $compiler;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->fileUtility = Files::init();
|
||||
|
||||
$this->validationStateMock = $this->getMockBuilder(ValidationStateInterface::class)
|
||||
->setMethods(['isValidationRequired'])
|
||||
->getMockForAbstractClass();
|
||||
$this->schemaLocatorMock = $this->getMockBuilder(SchemaLocator::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPerFileSchema'])
|
||||
->getMock();
|
||||
$this->fileResolverMock = $this->getMockBuilder(FileResolverInterface::class)
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->validationStateMock->expects($this->atLeastOnce())
|
||||
->method('isValidationRequired')
|
||||
->willReturn(false);
|
||||
$this->schemaLocatorMock->expects($this->atLeastOnce())
|
||||
->method('getPerFileSchema')
|
||||
->willReturn(false);
|
||||
|
||||
$this->converter = $this->objectManager->create(ConverterStub::class);
|
||||
|
||||
//Isolate test from actual configuration, and leave only sample data.
|
||||
$this->compiler = $this->getMockBuilder(CompilerInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['compile'])
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$this->reader = $this->objectManager->create(
|
||||
ReaderStub::class,
|
||||
[
|
||||
'fileResolver' => $this->fileResolverMock,
|
||||
'converter' => $this->converter,
|
||||
'schemaLocator' => $this->schemaLocatorMock,
|
||||
'validationState' => $this->validationStateMock,
|
||||
'fileName' => 'no_existing_file.xml',
|
||||
'compiler' => $this->compiler,
|
||||
'domDocumentClass' => Dom::class
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The test checks the file structure after processing the nodes responsible for inserting content.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testXmlConvertedConfigurationAndCompereStructure()
|
||||
{
|
||||
$actual = $this->reader->readFiles(['actual' => $this->getContent()]);
|
||||
|
||||
$document = new \DOMDocument();
|
||||
$document->loadXML($this->getContent());
|
||||
|
||||
$expected = $this->converter->getArrayData($document);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config sample data for test.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getContent()
|
||||
{
|
||||
$files = $this->fileUtility->getFiles([BP . static::CONFIG], 'config.xml');
|
||||
|
||||
return file_get_contents(reset($files));
|
||||
}
|
||||
}
|
||||
+373
@@ -0,0 +1,373 @@
|
||||
<?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_Config:etc/system_file.xsd">
|
||||
<system>
|
||||
<section id="payment">
|
||||
<group id="account" translate="label" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Merchant Location</label>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<field id="merchant_country" type="select" translate="label comment" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Merchant Country</label>
|
||||
<comment>If not specified, Default Country from General Config will be used.</comment>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Field\Country</frontend_model>
|
||||
<source_model>Magento\Paypal\Model\System\Config\Source\MerchantCountry</source_model>
|
||||
<backend_model>Magento\Paypal\Model\System\Config\Backend\MerchantCountry</backend_model>
|
||||
<config_path>paypal/general/merchant_country</config_path>
|
||||
</field>
|
||||
</group>
|
||||
<group id="recommended_solutions" translate="label" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Recommended Solutions:</label>
|
||||
<fieldset_css>paypal-top-section paypal-recommended-header</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
</group>
|
||||
<group id="other_paypal_payment_solutions" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Other PayPal Payment Solutions:</label>
|
||||
<fieldset_css>paypal-top-section paypal-other-header</fieldset_css>
|
||||
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
|
||||
</group>
|
||||
<group id="other_payment_methods" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Other Payment Methods:</label>
|
||||
<fieldset_css>paypal-top-section payments-other-header</fieldset_css>
|
||||
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_all_paypal" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<include path="Magento_Paypal::system/paypal_payflowpro.xml"/>
|
||||
<include path="Magento_Paypal::system/payflow_link.xml"/>
|
||||
<include path="Magento_Paypal::system/express_checkout.xml"/>
|
||||
<include path="Magento_Paypal::system/payments_pro_hosted_solution.xml"/>
|
||||
<group id="payments_pro_hosted_solution_without_bml" extends="payments_pro_hosted_solution">
|
||||
<group id="pphs_required_settings">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="pphs_advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_us" extends="payment" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="paypal_alternative_payment_methods" sortOrder="5" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="express_checkout_us" translate="label comment" extends="payment_all_paypal/express_checkout" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>PayPal Express Checkout</label>
|
||||
<fieldset_css>complex paypal-express-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
|
||||
<comment>Add another payment method to your existing solution or as a stand-alone option.</comment>
|
||||
<help_url>https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content</help_url>
|
||||
<attribute type="shared">0</attribute>
|
||||
<attribute type="activity_path">payment/paypal_express/active</attribute>
|
||||
<attribute type="activity_path">payment/payflow_express/active</attribute>
|
||||
<attribute type="displayIn">recommended_solutions</attribute>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_group_all_in_one" translate="label comment" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label><![CDATA[PayPal All-in-One Payment Solutions <i>Accept and process credit cards and PayPal payments.</i>]]></label>
|
||||
<fieldset_css>complex paypal-other-section paypal-all-in-one-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<comment>Choose a secure bundled payment solution for your business.</comment>
|
||||
<attribute type="displayIn">other_paypal_payment_solutions</attribute>
|
||||
<include path="Magento_Paypal::system/payflow_advanced.xml"/>
|
||||
<group id="wpp_usuk" translate="label" sortOrder="40" extends="payment_us/paypal_payment_gateways/paypal_payflowpro_with_express_checkout">
|
||||
<label>Payments Pro</label>
|
||||
<attribute type="activity_path">payment/paypal_payment_pro/active</attribute>
|
||||
<group id="configuration_details">
|
||||
<comment>https://docs.magento.com/user-guide/payment/paypal-payments-pro.html</comment>
|
||||
</group>
|
||||
<group id="paypal_payflow_required" translate="label" showInDefault="1" showInWebsite="1" sortOrder="10">
|
||||
<field id="enable_paypal_payflow">
|
||||
<attribute type="shared">0</attribute>
|
||||
<config_path>payment/paypal_payment_pro/active</config_path>
|
||||
</field>
|
||||
<group id="paypal_payflow_api_settings" translate="label">
|
||||
<label>Payments Pro and Express Checkout</label>
|
||||
</group>
|
||||
</group>
|
||||
<group id="settings_paypal_payflow" translate="label">
|
||||
<label>Basic Settings - PayPal Payments Pro</label>
|
||||
</group>
|
||||
</group>
|
||||
<group id="wps_express" extends="payment_all_paypal/express_checkout">
|
||||
<label>Payments Standard</label>
|
||||
<comment>Accept credit card and PayPal payments securely.</comment>
|
||||
<attribute type="activity_path">payment/wps_express/active</attribute>
|
||||
<group id="configuration_details">
|
||||
<comment>https://docs.magento.com/user-guide/payment/paypal-payments-standard.html</comment>
|
||||
</group>
|
||||
<group id="express_checkout_required">
|
||||
<group id="express_checkout_required_express_checkout">
|
||||
<label>Payments Standard</label>
|
||||
</group>
|
||||
<field id="enable_in_context_checkout" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="merchant_id" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="enable_express_checkout">
|
||||
<config_path>payment/wps_express/active</config_path>
|
||||
</field>
|
||||
<field id="enable_express_checkout_bml">
|
||||
<config_path>payment/wps_express_bml/active</config_path>
|
||||
</field>
|
||||
</group>
|
||||
<group id="settings_ec">
|
||||
<label>Basic Settings - PayPal Website Payments Standard</label>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_payment_gateways" translate="label" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label><![CDATA[PayPal Payment Gateways <i>Process payments using your own internet merchant account.</i>]]></label>
|
||||
<fieldset_css>complex paypal-other-section paypal-gateways-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<attribute type="displayIn">other_paypal_payment_solutions</attribute>
|
||||
<include path="Magento_Paypal::system/paypal_payflowpro_with_express_checkout.xml"/>
|
||||
<group id="payflow_link_us" extends="payment_all_paypal/payflow_link"/>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_gb" extends="payment" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="paypal_alternative_payment_methods" sortOrder="5" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="express_checkout_gb" translate="label comment" extends="payment_all_paypal/express_checkout" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>PayPal Express Checkout</label>
|
||||
<fieldset_css>complex paypal-express-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
|
||||
<comment>Add another payment method to your existing solution or as a stand-alone option.</comment>
|
||||
<help_url>https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content</help_url>
|
||||
<attribute type="displayIn">recommended_solutions</attribute>
|
||||
<group id="express_checkout_required">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_group_all_in_one" translate="label comment" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label><![CDATA[PayPal All-in-One Payment Solutions <i>Accept and process credit cards and PayPal payments.</i>]]></label>
|
||||
<fieldset_css>complex paypal-other-section paypal-all-in-one-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<comment>Choose a secure bundled payment solution for your business.</comment>
|
||||
<help_url>https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup</help_url>
|
||||
<attribute type="displayIn">other_paypal_payment_solutions</attribute>
|
||||
<group id="wpp_usuk" translate="comment" sortOrder="20">
|
||||
<fieldset_css>pp-general-uk</fieldset_css>
|
||||
<demo_link>http://www.youtube.com/watch?v=LBe-TW87eGI&list=PLF18B1094ABCD7CE8&index=1&feature=plpp_video</demo_link>
|
||||
<comment>Accept payments with a completely customizable checkout page.</comment>
|
||||
<group id="wpp_required_settings">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="wpp_advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
<include path="Magento_Paypal::system/payments_pro_hosted_solution_with_express_checkout.xml"/>
|
||||
<group id="wps_express" extends="payment_all_paypal/express_checkout" sortOrder="50">
|
||||
<label>Website Payments Standard</label>
|
||||
<comment>Accept credit card and PayPal payments securely.</comment>
|
||||
<attribute type="activity_path">payment/wps_express/active</attribute>
|
||||
<group id="configuration_details">
|
||||
<comment>https://docs.magento.com/user-guide/payment/paypal-payments-standard.html</comment>
|
||||
</group>
|
||||
<group id="express_checkout_required">
|
||||
<group id="express_checkout_required_express_checkout">
|
||||
<label>Website Payments Standard</label>
|
||||
</group>
|
||||
<field id="enable_in_context_checkout" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="merchant_id" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="enable_express_checkout">
|
||||
<config_path>payment/wps_express/active</config_path>
|
||||
</field>
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
<group id="settings_ec">
|
||||
<label>Basic Settings - PayPal Website Payments Standard</label>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_de" extends="payment" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="paypal_payment_solutions" sortOrder="5" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="express_checkout_de" translate="label comment" extends="payment_all_paypal/express_checkout" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>PayPal Express Checkout</label>
|
||||
<fieldset_css>complex paypal-express-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
|
||||
<comment>Add another payment method to your existing solution or as a stand-alone option.</comment>
|
||||
<help_url>https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup</help_url>
|
||||
<attribute type="displayIn">recommended_solutions</attribute>
|
||||
<group id="express_checkout_required">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
<group id="settings_ec">
|
||||
<group id="settings_ec_advanced">
|
||||
<field id="solution_type" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_other" extends="payment" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<group id="express_checkout_other" translate="label comment" sortOrder="5" extends="payment_all_paypal/express_checkout" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>PayPal Express Checkout</label>
|
||||
<fieldset_css>complex paypal-express-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
|
||||
<comment>Add another payment method to your existing solution or as a stand-alone option.</comment>
|
||||
<help_url>https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup</help_url>
|
||||
<attribute type="displayIn">recommended_solutions</attribute>
|
||||
<group id="express_checkout_required">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_group_all_in_one" translate="label comment" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label><![CDATA[PayPal All-in-One Payment Solutions <i>Accept and process credit cards and PayPal payments.</i>]]></label>
|
||||
<fieldset_css>complex paypal-other-section paypal-all-in-one-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<comment>Choose a secure bundled payment solution for your business.</comment>
|
||||
<help_url>https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup</help_url>
|
||||
<attribute type="displayIn">other_paypal_payment_solutions</attribute>
|
||||
<group id="wps_other" extends="payment_all_paypal/express_checkout" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>Website Payments Standard</label>
|
||||
<fieldset_css>complex</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
|
||||
<comment>Accept credit card and PayPal payments securely.</comment>
|
||||
<attribute type="activity_path">payment/wps_express/active</attribute>
|
||||
<group id="configuration_details">
|
||||
<comment>https://docs.magento.com/user-guide/payment/paypal-payments-standard.html</comment>
|
||||
</group>
|
||||
<group id="express_checkout_required">
|
||||
<group id="express_checkout_required_express_checkout">
|
||||
<label>Website Payments Standard</label>
|
||||
</group>
|
||||
<field id="enable_in_context_checkout" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="merchant_id" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="enable_express_checkout">
|
||||
<config_path>payment/wps_express/active</config_path>
|
||||
</field>
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
<group id="settings_ec">
|
||||
<label>Basic Settings - PayPal Website Payments Standard</label>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_payment_gateways" translate="label comment" sortOrder="8" showInDefault="0" showInWebsite="0" showInStore="0">
|
||||
<label><![CDATA[PayPal Payment Gateways <i>Process payments using your own internet merchant account.</i>]]></label>
|
||||
<fieldset_css>complex paypal-other-section paypal-gateways-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<comment>Process payments using your own internet merchant account.</comment>
|
||||
<help_url>https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content</help_url>
|
||||
<attribute type="displayIn">other_paypal_payment_solutions</attribute>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_ca" extends="payment_other">
|
||||
<group id="express_checkout_other">
|
||||
<attribute type="activity_path">payment/paypal_express/active</attribute>
|
||||
<attribute type="activity_path">payment/payflow_express/active</attribute>
|
||||
</group>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="20"/>
|
||||
</group>
|
||||
<group id="paypal_payment_gateways" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<fieldset_css>complex paypal-other-section paypal-gateways-section</fieldset_css>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model>
|
||||
<label><![CDATA[PayPal Payment Gateways <i>Process payments using your own internet merchant account.</i>]]></label>
|
||||
<group id="wpp_ca" translate="label" extends="payment_all_paypal/paypal_payflowpro" sortOrder="30">
|
||||
<label>Website Payments Pro</label>
|
||||
<attribute type="activity_path">payment/paypal_payment_pro/active</attribute>
|
||||
<group id="configuration_details">
|
||||
<comment>https://docs.magento.com/user-guide/payment/paypal-payments-pro.html</comment>
|
||||
</group>
|
||||
<group id="paypal_payflow_required" translate="label" showInDefault="1" showInWebsite="1" sortOrder="10">
|
||||
<group id="paypal_payflow_api_settings">
|
||||
<label>Payments Pro</label>
|
||||
</group>
|
||||
<field id="enable_in_context_checkout" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="merchant_id" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="enable_paypal_payflow">
|
||||
<frontend_class>paypal-enabler paypal-ec-pe</frontend_class>
|
||||
<attribute type="shared">0</attribute>
|
||||
<config_path>payment/paypal_payment_pro/active</config_path>
|
||||
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Field\Enable\Payment</frontend_model>
|
||||
</field>
|
||||
</group>
|
||||
<group id="settings_paypal_payflow">
|
||||
<label>Basic Settings - PayPal Payments Pro</label>
|
||||
</group>
|
||||
</group>
|
||||
<group id="paypal_payflowpro_ca" extends="payment_all_paypal/paypal_payflowpro" sortOrder="40"/>
|
||||
<group id="payflow_link_ca" extends="payment_all_paypal/payflow_link" sortOrder="50">
|
||||
<group id="payflow_link_required">
|
||||
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
|
||||
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
|
||||
<group id="payflow_link_advertise_bml" showInDefault="0" showInWebsite="0"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_au" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_au" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10"/>
|
||||
</group>
|
||||
<group id="paypal_payment_gateways" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<group id="paypal_payflowpro_au" extends="payment_all_paypal/paypal_payflowpro" sortOrder="20"/>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_jp" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_jp" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10">
|
||||
<label>Website Payments Plus</label>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_fr" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_fr" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10">
|
||||
<label>Integral Evolution</label>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_it" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_it" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10">
|
||||
<label>Pro</label>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_es" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_es" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10">
|
||||
<label>Pasarela integral</label>
|
||||
</group>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_hk" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other" sortOrder="12"/>
|
||||
<group id="payments_pro_hosted_solution_hk" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10"/>
|
||||
</group>
|
||||
</section>
|
||||
<section id="payment_nz" extends="payment_other">
|
||||
<group id="express_checkout_other"/>
|
||||
<group id="paypal_group_all_in_one">
|
||||
<group id="wps_other"/>
|
||||
</group>
|
||||
<group id="paypal_payment_gateways" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<group id="paypal_payflowpro_nz" extends="payment_all_paypal/paypal_payflowpro"/>
|
||||
</group>
|
||||
</section>
|
||||
</system>
|
||||
</config>
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model;
|
||||
|
||||
use Magento\Backend\App\Area\FrontNameResolver;
|
||||
use Magento\Config\Model\ResourceModel\Config\Data\Collection;
|
||||
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
|
||||
use Magento\Framework\Config\ScopeInterface;
|
||||
use Magento\Framework\Encryption\EncryptorInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \Magento\Config\Model\Config::save
|
||||
* @param array $groups
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider saveWithSingleStoreModeEnabledDataProvider
|
||||
* @magentoConfigFixture current_store general/single_store_mode/enabled 1
|
||||
*/
|
||||
public function testSaveWithSingleStoreModeEnabled($groups)
|
||||
{
|
||||
Bootstrap::getObjectManager()->get(
|
||||
ScopeInterface::class
|
||||
)->setCurrentScope(
|
||||
FrontNameResolver::AREA_CODE
|
||||
);
|
||||
/** @var $_configDataObject Config */
|
||||
$_configDataObject = Bootstrap::getObjectManager()->create(Config::class);
|
||||
$_configData = $_configDataObject->setSection('dev')->setWebsite('base')->load();
|
||||
$this->assertEmpty($_configData);
|
||||
|
||||
$_configDataObject = Bootstrap::getObjectManager()->create(Config::class);
|
||||
$_configDataObject->setSection('dev')->setGroups($groups)->save();
|
||||
|
||||
/** @var $_configDataObject Config */
|
||||
$_configDataObject = Bootstrap::getObjectManager()->create(Config::class);
|
||||
$_configData = $_configDataObject->setSection('dev')->load();
|
||||
$this->assertArrayHasKey('dev/debug/template_hints_admin', $_configData);
|
||||
$this->assertArrayHasKey('dev/debug/template_hints_blocks', $_configData);
|
||||
|
||||
$_configDataObject = Bootstrap::getObjectManager()->create(Config::class);
|
||||
$_configData = $_configDataObject->setSection('dev')->setWebsite('base')->load();
|
||||
$this->assertArrayNotHasKey('dev/debug/template_hints_admin', $_configData);
|
||||
$this->assertArrayNotHasKey('dev/debug/template_hints_blocks', $_configData);
|
||||
}
|
||||
|
||||
public function saveWithSingleStoreModeEnabledDataProvider()
|
||||
{
|
||||
return require __DIR__ . '/_files/config_groups.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Config\Model\Config::save
|
||||
* @param string $section
|
||||
* @param array $groups
|
||||
* @param array $expected
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider saveDataProvider
|
||||
*/
|
||||
public function testSave($section, $groups, $expected)
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
/** @var $_configDataObject Config */
|
||||
$_configDataObject = $objectManager->create(Config::class);
|
||||
$_configDataObject->setSection($section)->setWebsite('base')->setGroups($groups)->save();
|
||||
|
||||
foreach ($expected as $group => $expectedData) {
|
||||
$_configDataObject = $objectManager->create(Config::class);
|
||||
$_configData = $_configDataObject->setSection($group)->setWebsite('base')->load();
|
||||
if (array_key_exists('payment/payflow_link/pwd', $_configData)) {
|
||||
$_configData['payment/payflow_link/pwd'] = $objectManager->get(
|
||||
EncryptorInterface::class
|
||||
)->decrypt(
|
||||
$_configData['payment/payflow_link/pwd']
|
||||
);
|
||||
}
|
||||
$this->assertEquals($expectedData, $_configData);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveDataProvider()
|
||||
{
|
||||
return require __DIR__ . '/_files/config_section.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $website
|
||||
* @param string $section
|
||||
* @param array $override
|
||||
* @param array $inherit
|
||||
* @param array $expected
|
||||
* @dataProvider saveWebsiteScopeDataProvider
|
||||
*/
|
||||
public function testSaveUseDefault(
|
||||
string $website,
|
||||
string $section,
|
||||
array $override,
|
||||
array $inherit,
|
||||
array $expected
|
||||
): void {
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Config $config*/
|
||||
$configFactory = $objectManager->create(ConfigFactory::class);
|
||||
$config = $configFactory->create()
|
||||
->setSection($section)
|
||||
->setWebsite($website)
|
||||
->setGroups($override['groups'])
|
||||
->save();
|
||||
|
||||
$paths = array_keys($expected);
|
||||
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->getConfigValues($config->getScope(), $config->getScopeId(), $paths)
|
||||
);
|
||||
|
||||
$config = $configFactory->create()
|
||||
->setSection($section)
|
||||
->setWebsite($website)
|
||||
->setGroups($inherit['groups'])
|
||||
->save();
|
||||
|
||||
$this->assertEmpty(
|
||||
$this->getConfigValues($config->getScope(), $config->getScopeId(), $paths)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function saveWebsiteScopeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'website' => 'base',
|
||||
'section' => 'payment',
|
||||
[
|
||||
'groups' => [
|
||||
'account' => [
|
||||
'fields' => [
|
||||
'merchant_country' => ['value' => 'GB'],
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'groups' => [
|
||||
'account' => [
|
||||
'fields' => [
|
||||
'merchant_country' => ['inherit' => 1],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'paypal/general/merchant_country' => 'GB',
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scope
|
||||
* @param int $scopeId
|
||||
* @param array $paths
|
||||
* @return array
|
||||
*/
|
||||
private function getConfigValues(string $scope, int $scopeId, array $paths): array
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Collection $configCollection */
|
||||
$configCollectionFactory = $objectManager->create(CollectionFactory::class);
|
||||
$configCollection = $configCollectionFactory->create();
|
||||
$configCollection->addFieldToFilter('scope', $scope);
|
||||
$configCollection->addFieldToFilter('scope_id', $scopeId);
|
||||
$configCollection->addFieldToFilter('path', ['in' => $paths]);
|
||||
$result = [];
|
||||
foreach ($configCollection as $data) {
|
||||
$result[$data->getPath()] = $data->getValue();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Config\Model\ResourceModel;
|
||||
|
||||
class ConfigTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Config\Model\ResourceModel\Config
|
||||
*/
|
||||
protected $_model;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Config\Model\ResourceModel\Config::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testSaveDeleteConfig()
|
||||
{
|
||||
$connection = $this->_model->getConnection();
|
||||
$select = $connection->select()->from($this->_model->getMainTable())->where('path=?', 'test/config');
|
||||
$this->_model->saveConfig('test/config', 'test', 'default', 0);
|
||||
$this->assertNotEmpty($connection->fetchRow($select));
|
||||
|
||||
$this->_model->deleteConfig('test/config', 'default', 0);
|
||||
$this->assertEmpty($connection->fetchRow($select));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
return [
|
||||
[
|
||||
'groups' => [
|
||||
'restrict' => ['fields' => ['allow_ips' => ['value' => '']]],
|
||||
'debug' => [
|
||||
'fields' => [
|
||||
'template_hints_admin' => ['value' => '0'],
|
||||
'template_hints_blocks' => ['value' => '0'],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
return [
|
||||
[
|
||||
'section' => 'dev',
|
||||
'groups' => [
|
||||
'log' => [
|
||||
'fields' => [
|
||||
'active' => ['value' => '1'],
|
||||
'file' => ['value' => 'fileName.log'],
|
||||
'exception_file' => ['value' => 'exceptionFileName.log'],
|
||||
],
|
||||
],
|
||||
'debug' => [
|
||||
'fields' => [
|
||||
'template_hints_storefront' => ['value' => '1'],
|
||||
'template_hints_blocks' => ['value' => '0'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
'dev/log' => [
|
||||
'dev/log/active' => '1',
|
||||
'dev/log/file' => 'fileName.log',
|
||||
'dev/log/exception_file' => 'exceptionFileName.log',
|
||||
],
|
||||
'dev/debug' => [
|
||||
'dev/debug/template_hints_storefront' => '1',
|
||||
'dev/debug/template_hints_blocks' => '0',
|
||||
],
|
||||
],
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
|
||||
/** @var \Magento\Framework\Filesystem\Directory\Write $rootDirectory */
|
||||
$rootDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\Filesystem::class
|
||||
)->getDirectoryWrite(
|
||||
DirectoryList::PUB
|
||||
);
|
||||
if ($rootDirectory->isExist('robots.txt')) {
|
||||
$rootDirectory->delete('robots.txt');
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Sitemap: http://store.com/sitemap.xml
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/** @var $fileSystem Filesystem */
|
||||
$fileSystem = Bootstrap::getObjectManager()->get(Filesystem::class);
|
||||
$pubDirectory = $fileSystem->getDirectoryWrite(DirectoryList::PUB);
|
||||
$rootDirectory = $fileSystem->getDirectoryRead(DirectoryList::ROOT);
|
||||
$source = $rootDirectory->getAbsolutePath(__DIR__ . '/robots.txt');
|
||||
$content = $rootDirectory->readFile(__DIR__ . '/robots.txt');
|
||||
$pubDirectory->writeFile('robots.txt', $content);
|
||||
Reference in New Issue
Block a user