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

Public Member Functions

 testGetExistingCreateAccountUrl ()
 
 testGetCreateAccountUrlWithContext ()
 
 testGetCreateAccountUrl ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $block
 
 $customerUrl
 
 $checkoutData
 
 $coreUrl
 

Detailed Description

Definition at line 8 of file InfoTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 30 of file InfoTest.php.

31  {
32  $this->customerUrl = $this->getMockBuilder(
33  \Magento\Customer\Model\Url::class
34  )->disableOriginalConstructor()->setMethods(
35  ['getRegisterUrl']
36  )->getMock();
37  $this->checkoutData = $this->getMockBuilder(
38  \Magento\Checkout\Helper\Data::class
39  )->disableOriginalConstructor()->setMethods(
40  ['isContextCheckout']
41  )->getMock();
42  $this->coreUrl = $this->getMockBuilder(
43  \Magento\Framework\Url\Helper\Data::class
44  )->disableOriginalConstructor()->setMethods(
45  ['addRequestParam']
46  )->getMock();
47 
48  $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
49  \Magento\Customer\Block\Form\Login\Info::class,
50  [
51  'customerUrl' => $this->customerUrl,
52  'checkoutData' => $this->checkoutData,
53  'coreUrl' => $this->coreUrl
54  ]
55  );
56  }

◆ testGetCreateAccountUrl()

testGetCreateAccountUrl ( )

Definition at line 87 of file InfoTest.php.

88  {
89  $expectedUrl = 'Custom Url';
90 
91  $this->customerUrl->expects($this->any())->method('getRegisterUrl')->will($this->returnValue($expectedUrl));
92  $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false));
93  $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl());
94  }

◆ testGetCreateAccountUrlWithContext()

testGetCreateAccountUrlWithContext ( )

Definition at line 67 of file InfoTest.php.

68  {
69  $url = 'Custom Url';
70  $expectedUrl = 'Custom Url with context';
71  $this->block->setCreateAccountUrl($url);
72 
73  $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(true));
74  $this->coreUrl->expects(
75  $this->any()
76  )->method(
77  'addRequestParam'
78  )->with(
79  $url,
80  ['context' => 'checkout']
81  )->will(
82  $this->returnValue($expectedUrl)
83  );
84  $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl());
85  }

◆ testGetExistingCreateAccountUrl()

testGetExistingCreateAccountUrl ( )

Definition at line 58 of file InfoTest.php.

59  {
60  $expectedUrl = 'Custom Url';
61 
62  $this->block->setCreateAccountUrl($expectedUrl);
63  $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false));
64  $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl());
65  }

Field Documentation

◆ $block

$block
protected

Definition at line 13 of file InfoTest.php.

◆ $checkoutData

$checkoutData
protected

Definition at line 23 of file InfoTest.php.

◆ $coreUrl

$coreUrl
protected

Definition at line 28 of file InfoTest.php.

◆ $customerUrl

$customerUrl
protected

Definition at line 18 of file InfoTest.php.


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