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

Public Member Functions

 testGetCustomerName ( $customerData, $expectedCustomerName, $isPrefixAllowed=false, $isMiddleNameAllowed=false, $isSuffixAllowed=false)
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_helper
 
 $_customerMetadataService
 

Detailed Description

Definition at line 11 of file ViewTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 19 of file ViewTest.php.

20  {
21  $this->_customerMetadataService = $this->createMock(\Magento\Customer\Api\CustomerMetadataInterface::class);
22  $this->_helper = Bootstrap::getObjectManager()->create(
23  \Magento\Customer\Helper\View::class,
24  ['customerMetadataService' => $this->_customerMetadataService]
25  );
26  parent::setUp();
27  }

◆ testGetCustomerName()

testGetCustomerName (   $customerData,
  $expectedCustomerName,
  $isPrefixAllowed = false,
  $isMiddleNameAllowed = false,
  $isSuffixAllowed = false 
)
Parameters
\Magento\Customer\Api\Data\CustomerInterface$customerData
string$expectedCustomerName
bool$isPrefixAllowed
bool$isMiddleNameAllowed
bool$isSuffixAllowed@dataProvider getCustomerNameDataProvider

Definition at line 37 of file ViewTest.php.

43  {
44  $visibleAttribute = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class);
45  $visibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(true));
46 
47  $invisibleAttribute = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class);
48  $invisibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
49 
50  $this->_customerMetadataService->expects(
51  $this->any()
52  )->method(
53  'getAttributeMetadata'
54  )->will(
55  $this->returnValueMap(
56  [
57  ['prefix', $isPrefixAllowed ? $visibleAttribute : $invisibleAttribute],
58  ['middlename', $isMiddleNameAllowed ? $visibleAttribute : $invisibleAttribute],
59  ['suffix', $isSuffixAllowed ? $visibleAttribute : $invisibleAttribute],
60  ]
61  )
62  );
63 
64  $this->assertEquals(
65  $expectedCustomerName,
66  $this->_helper->getCustomerName($customerData),
67  'Full customer name is invalid'
68  );
69  }
$customerData

Field Documentation

◆ $_customerMetadataService

$_customerMetadataService
protected

Definition at line 17 of file ViewTest.php.

◆ $_helper

$_helper
protected

Definition at line 14 of file ViewTest.php.


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