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

Public Member Functions

 testGetUrl (string $routePath, array $requestParams, string $expectedResult, $routeParams=null)
 
 testGetSecretKey (string $routeName, string $controller, string $action, string $expectedHash)
 
 testUseSecretKey ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

Test class for \Magento\Backend\Model\UrlInterface.

@magentoAppArea adminhtml

Definition at line 20 of file UrlTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 40 of file UrlTest.php.

41  {
42  $this->objectManager = Bootstrap::getObjectManager();
43  $this->request = $this->objectManager->get(RequestInterface::class);
44  $this->_model = $this->objectManager->create(UrlInterface::class);
45  }

◆ testGetSecretKey()

testGetSecretKey ( string  $routeName,
string  $controller,
string  $action,
string  $expectedHash 
)
Parameters
string$routeName
string$controller
string$action
string$expectedHash
Returns
void

@dataProvider getSecretKeyDataProvider @magentoAppIsolation enabled

Definition at line 150 of file UrlTest.php.

150  : void
151  {
152  $this->request->setControllerName('default_controller')
153  ->setActionName('default_action')
154  ->setRouteName('default_router');
155 
156  $this->_model->setRequest($this->request);
157  $this->objectManager->get(SessionManagerInterface::class)->setData('_form_key', 'salt');
158 
159  $this->assertEquals($expectedHash, $this->_model->getSecretKey($routeName, $controller, $action));
160  }
$controller
Definition: info.phtml:14

◆ testGetUrl()

testGetUrl ( string  $routePath,
array  $requestParams,
string  $expectedResult,
  $routeParams = null 
)

App isolation is enabled to protect next tests from polluted registry by getUrl().

Parameters
string$routePath
array$requestParams
string$expectedResult
array | null$routeParams
Returns
void

@dataProvider getUrlDataProvider @magentoAppIsolation enabled

Definition at line 59 of file UrlTest.php.

64  : void {
65  $this->request->setParams($requestParams);
66  $url = $this->_model->getUrl($routePath, $routeParams);
67 
68  $this->assertContains($expectedResult, $url);
69  }

◆ testUseSecretKey()

testUseSecretKey ( )
Returns
void

Definition at line 237 of file UrlTest.php.

237  : void
238  {
239  $this->_model->setNoSecret(true);
240  $this->assertFalse($this->_model->useSecretKey());
241 
242  $this->_model->setNoSecret(false);
243  $this->assertTrue($this->_model->useSecretKey());
244  }

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