Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
FrontNameResolverTest Class Reference
Inheritance diagram for FrontNameResolverTest:

Public Member Functions

 testIfCustomPathUsed ()
 
 testIfCustomPathNotUsed ()
 
 testIsHostBackend ($url, $host, $useCustomAdminUrl, $customAdminUrl, $expectedValue)
 
 hostsDataProvider ()
 

Protected Attributes

 $model
 
 $configMock
 
 $scopeConfigMock
 
 $_defaultFrontName = 'defaultFrontName'
 

Detailed Description

Definition at line 14 of file FrontNameResolverTest.php.

Member Function Documentation

◆ hostsDataProvider()

hostsDataProvider ( )
Returns
array

Definition at line 124 of file FrontNameResolverTest.php.

125  {
126  return [
127  'withoutPort' => [
128  'url' => 'http://magento2.loc/',
129  'host' => 'magento2.loc',
130  'useCustomAdminUrl' => '0',
131  'customAdminUrl' => '',
132  'expectedValue' => true
133  ],
134  'withPort' => [
135  'url' => 'http://magento2.loc:8080/',
136  'host' => 'magento2.loc:8080',
137  'useCustomAdminUrl' => '0',
138  'customAdminUrl' => '',
139  'expectedValue' => true
140  ],
141  'withStandartPortInUrlWithoutPortInHost' => [
142  'url' => 'http://magento2.loc:80/',
143  'host' => 'magento2.loc',
144  'useCustomAdminUrl' => '0',
145  'customAdminUrl' => '',
146  'expectedValue' => true
147  ],
148  'withoutStandartPortInUrlWithPortInHost' => [
149  'url' => 'https://magento2.loc/',
150  'host' => 'magento2.loc:443',
151  'useCustomAdminUrl' => '0',
152  'customAdminUrl' => '',
153  'expectedValue' => true
154  ],
155  'differentHosts' => [
156  'url' => 'http://m2.loc/',
157  'host' => 'magento2.loc',
158  'useCustomAdminUrl' => '0',
159  'customAdminUrl' => '',
160  'expectedValue' => false
161  ],
162  'differentPortsOnOneHost' => [
163  'url' => 'http://magento2.loc/',
164  'host' => 'magento2.loc:8080',
165  'useCustomAdminUrl' => '0',
166  'customAdminUrl' => '',
167  'expectedValue' => false
168  ],
169  'withCustomAdminUrl' => [
170  'url' => 'http://magento2.loc/',
171  'host' => 'myhost.loc',
172  'useCustomAdminUrl' => '1',
173  'customAdminUrl' => 'https://myhost.loc/',
174  'expectedValue' => true
175  ],
176  'withCustomAdminUrlWrongHost' => [
177  'url' => 'http://magento2.loc/',
178  'host' => 'SomeOtherHost.loc',
179  'useCustomAdminUrl' => '1',
180  'customAdminUrl' => 'https://myhost.loc/',
181  'expectedValue' => false
182  ]
183  ];
184  }
return false
Definition: gallery.phtml:36

◆ testIfCustomPathNotUsed()

testIfCustomPathNotUsed ( )

Definition at line 72 of file FrontNameResolverTest.php.

73  {
74  $this->configMock->expects(
75  $this->once()
76  )->method(
77  'getValue'
78  )->with(
79  'admin/url/use_custom_path'
80  )->will(
81  $this->returnValue(false)
82  );
83  $this->assertEquals($this->_defaultFrontName, $this->model->getFrontName());
84  }

◆ testIfCustomPathUsed()

testIfCustomPathUsed ( )

Definition at line 49 of file FrontNameResolverTest.php.

50  {
51  $this->configMock->expects(
52  $this->at(0)
53  )->method(
54  'getValue'
55  )->with(
56  'admin/url/use_custom_path'
57  )->will(
58  $this->returnValue(true)
59  );
60  $this->configMock->expects(
61  $this->at(1)
62  )->method(
63  'getValue'
64  )->with(
65  'admin/url/custom_path'
66  )->will(
67  $this->returnValue('expectedValue')
68  );
69  $this->assertEquals('expectedValue', $this->model->getFrontName());
70  }

◆ testIsHostBackend()

testIsHostBackend (   $url,
  $host,
  $useCustomAdminUrl,
  $customAdminUrl,
  $expectedValue 
)
Parameters
string$url
string$host
string$useCustomAdminUrl
string$customAdminUrl
string$expectedValue@dataProvider hostsDataProvider

Definition at line 94 of file FrontNameResolverTest.php.

95  {
96  $_SERVER['HTTP_HOST'] = $host;
97  $this->scopeConfigMock->expects($this->exactly(2))
98  ->method('getValue')
99  ->will(
100  $this->returnValueMap(
101  [
103  [
106  null,
107  $useCustomAdminUrl
108  ],
109  [
112  null,
113  $customAdminUrl
114  ],
115  ]
116  )
117  );
118  $this->assertEquals($this->model->isHostBackend(), $expectedValue);
119  }
const XML_PATH_UNSECURE_BASE_URL
Definition: Store.php:66

Field Documentation

◆ $_defaultFrontName

$_defaultFrontName = 'defaultFrontName'
protected

Definition at line 34 of file FrontNameResolverTest.php.

◆ $configMock

$configMock
protected

Definition at line 24 of file FrontNameResolverTest.php.

◆ $model

$model
protected

Definition at line 19 of file FrontNameResolverTest.php.

◆ $scopeConfigMock

$scopeConfigMock
protected

Definition at line 29 of file FrontNameResolverTest.php.


The documentation for this class was generated from the following file: