1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Store\Test\Unit\Model\Config;
use Magento\Store\Model\Store;
class PlaceholderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Store\Model\Config\Processor\Placeholder
*/
protected $_model;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $_requestMock;
protected function setUp()
{
$this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
$this->_requestMock->expects(
$this->once()
)->method(
'getDistroBaseUrl'
)->will(
$this->returnValue('http://localhost/')
);
$this->_model = new \Magento\Store\Model\Config\Placeholder(
$this->_requestMock,
[
'unsecureBaseUrl' => Store::XML_PATH_UNSECURE_BASE_URL,
'secureBaseUrl' => Store::XML_PATH_SECURE_BASE_URL
],
\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER
);
}
public function testProcess()
{
$data = [
'web' => [
'unsecure' => [
'base_url' => 'http://localhost/',
'base_link_url' => '{{unsecure_base_url}}website/de',
],
'secure' => [
'base_url' => 'https://localhost/',
'base_link_url' => '{{secure_base_url}}website/de',
],
],
'path' => 'value',
'some_url' => '{{base_url}}some',
];
$expectedResult = $data;
$expectedResult['web']['unsecure']['base_link_url'] = 'http://localhost/website/de';
$expectedResult['web']['secure']['base_link_url'] = 'https://localhost/website/de';
$expectedResult['some_url'] = 'http://localhost/some';
$this->assertEquals($expectedResult, $this->_model->process($data));
}
}