![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-config/Test/Unit/Model/Placeholder/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Config\Test\Unit\Model\Placeholder; use Magento\Config\Model\Placeholder\Environment; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig; use PHPUnit\Framework\MockObject\MockObject as Mock; use PHPUnit\Framework\TestCase; class EnvironmentTest extends TestCase { /** * @var Environment */ private $model; /** * @var DeploymentConfig|Mock */ private $deploymentConfigMock; protected function setUp(): void { $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) ->disableOriginalConstructor() ->getMock(); $this->model = new Environment( $this->deploymentConfigMock ); } /** * @param string $path * @param string $scope * @param string $scopeId * @param string $expected * @dataProvider getGenerateDataProvider */ public function testGenerate($path, $scope, $scopeId, $expected) { $this->assertSame( $expected, $this->model->generate($path, $scope, $scopeId) ); } /** * @return array */ public function getGenerateDataProvider() { return [ [ 'web/unsecure/base_url', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, Environment::PREFIX . 'DEFAULT__WEB__UNSECURE__BASE_URL' ], [ 'web/unsecure/base_url', 'web', 'test', Environment::PREFIX . 'WEB__TEST__WEB__UNSECURE__BASE_URL' ], [ 'web/unsecure/base_url', 'web', null, Environment::PREFIX . 'WEB__WEB__UNSECURE__BASE_URL' ], ]; } /** * @param string $placeholder * @param bool $expected * @dataProvider getIsPlaceholderDataProvider */ public function testIsApplicable($placeholder, $expected) { $this->assertSame( $expected, $this->model->isApplicable($placeholder) ); } /** * @return array */ public function getIsPlaceholderDataProvider() { return [ [Environment::PREFIX . 'TEST', true], ['TEST', false], [Environment::PREFIX . 'TEST_test', true], [Environment::PREFIX . '-:A', false], [Environment::PREFIX . '_A', false], [Environment::PREFIX . 'A@#$', false] ]; } /** * @param string $template * @param string $expected * @dataProvider restoreDataProvider */ public function testRestore($template, $expected) { $this->assertSame( $expected, $this->model->restore($template) ); } /** * @return array */ public function restoreDataProvider() { return [ [Environment::PREFIX . 'TEST__CONFIG', 'test/config'], [Environment::PREFIX . 'TEST__CONFIG__VALUE', 'test/config/value'], [Environment::PREFIX . 'TEST__CONFIG_VALUE', 'test/config_value'], ]; } }