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

Public Member Functions

 testSetRefererUrl ()
 
 testSetRefererOrBaseUrl ()
 
 testSetUrl ()
 
 testSetPath ()
 
 httpRedirectResponseStatusCodes ()
 
 testRender ($expectedStatusCode, $actualStatusCode)
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $redirect
 
 $redirectInterface
 
 $urlBuilder
 
 $urlInterface
 
 $response
 

Detailed Description

Definition at line 15 of file RedirectTest.php.

Member Function Documentation

◆ httpRedirectResponseStatusCodes()

httpRedirectResponseStatusCodes ( )
Returns
array

Definition at line 81 of file RedirectTest.php.

82  {
83  return [
84  [302, null],
85  [302, 302],
86  [303, 303]
87  ];
88  }

◆ setUp()

setUp ( )
protected

Definition at line 32 of file RedirectTest.php.

33  {
34  $this->redirectInterface = $this->createMock(RedirectInterface::class);
35  $this->urlBuilder = $this->createMock(UrlInterface::class);
36  $this->urlInterface = $this->createMock(UrlInterface::class);
37  $this->response = $this->createMock(HttpResponseInterface::class);
38  $this->redirect = new Redirect($this->redirectInterface, $this->urlInterface);
39  }

◆ testRender()

testRender (   $expectedStatusCode,
  $actualStatusCode 
)
Parameters
int$expectedStatusCode
int | null$actualStatusCode@dataProvider httpRedirectResponseStatusCodes

Definition at line 95 of file RedirectTest.php.

96  {
97  $url = 'http://test.com';
98  $this->redirect->setUrl($url);
99  $this->redirect->setHttpResponseCode($actualStatusCode);
100 
101  $this->response
102  ->expects($this->once())
103  ->method('setRedirect')
104  ->with($url, $expectedStatusCode);
105 
106  $this->redirect->renderResult($this->response);
107  }

◆ testSetPath()

testSetPath ( )

Definition at line 65 of file RedirectTest.php.

66  {
67  $path = 'test/path';
68  $params = ['one' => 1, 'two' => 2];
69  $this->redirectInterface->expects($this->once())->method('updatePathParams')->with($params)->will(
70  $this->returnValue($params)
71  );
72  $this->assertInstanceOf(
73  Redirect::class,
74  $this->redirect->setPath($path, $params)
75  );
76  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ testSetRefererOrBaseUrl()

testSetRefererOrBaseUrl ( )

Definition at line 50 of file RedirectTest.php.

51  {
52  $this->redirectInterface->expects($this->once())->method('getRedirectUrl');
53  $this->assertInstanceOf(
54  Redirect::class,
55  $this->redirect->setRefererOrBaseUrl()
56  );
57  }

◆ testSetRefererUrl()

testSetRefererUrl ( )

Definition at line 41 of file RedirectTest.php.

42  {
43  $this->redirectInterface->expects($this->once())->method('getRefererUrl');
44  $this->assertInstanceOf(
45  Redirect::class,
46  $this->redirect->setRefererUrl()
47  );
48  }

◆ testSetUrl()

testSetUrl ( )

Definition at line 59 of file RedirectTest.php.

60  {
61  $url = 'http://test.com';
62  $this->assertInstanceOf(Redirect::class, $this->redirect->setUrl($url));
63  }

Field Documentation

◆ $redirect

$redirect
protected

Definition at line 18 of file RedirectTest.php.

◆ $redirectInterface

$redirectInterface
protected

Definition at line 21 of file RedirectTest.php.

◆ $response

$response
protected

Definition at line 30 of file RedirectTest.php.

◆ $urlBuilder

$urlBuilder
protected

Definition at line 24 of file RedirectTest.php.

◆ $urlInterface

$urlInterface
protected

Definition at line 27 of file RedirectTest.php.


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